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 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制