doutai1509 2016-07-07 12:39
浏览 127
已采纳

从PHP页面调用aspx文件

I have a PHP file, TableUpdates.php, that I am trying to add a menu to. I have 2 different menus based on who is logged in. I have a MenuCheck.aspx file that determines who is logged in and then include the correct Menu.php file. However, I can not get this to work. Here's the relevant part of TableUpdates.php:

<head>
    <meta charset="utf-8" />
    <title>Table Updates</title>
    <link rel="StyleSheet" href="StyleSheet.css" type="text/css">
</head>
<body>
    <!-- #include file="MenuCheck.aspx"-->

I've also tried switching out the <!-- #include file="MenuCheck.aspx"--> with:

<script type="text/javascript">
<% if (User.Identity.Name == @"CORP\mmm976") {%>
<!-- #include file="AdminMenu.php"-->
<% } else if (User.Identity.Name == @"CORP\ibb601"){%>
<!-- #include file="AdminMenu.php"-->
<% } else { %>
<!-- #include file="Menu.php"-->
<% } %>
</script>

Neither works. The MenuCheck.aspx is this:

<%@ Page Language="C#" %>

<% if (User.Identity.Name == @"CORP\mmm976") {%>
<!-- #include file="AdminMenu.php"-->
<% } else if (User.Identity.Name == @"CORP\ibb601"){%>
<!-- #include file="AdminMenu.php"-->
<% } else { %>
<!-- #include file="Menu.php"-->
<% } %>

What am I doing wrong that this does not work?

  • 写回答

3条回答 默认 最新

  • drh78568 2016-07-07 15:26
    关注

    I have ended up creating a PHP work around. Since I'm trying to get the authenticated user and base the menu on that I had my server admin turn off anonymous authentication so that the php $_SERVER['AUTH_USER'] would have the local user and not a blank. Then I added this to the php files in the body of the HTML for the menus:

        <?php  
            if ($_SERVER['AUTH_USER'] == 'CORP\mmm976'){
                include('AdminMenu.php');
            }elseif ($_SERVER['AUTH_USER'] == 'CORP\ibb601'){
                include('AdminMenu.php');
            }else {
                include('Menu.php');
            }
        ?>
    

    I still have the <!-- #include file="MenuCheck.aspx"--> in the body of the aspx files.

    So, although this doesn't actually call the aspx file and get the results in my php files, I still end up with the result that I wanted => the admins have access to the admin reports, everyone else has access to only the reports that they need.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM