位置路径安全无效

时间:2014-05-31 05:38:20

标签: asp.net security

我有以下设置,但是当我访问ManageContacts.aspx(来自IIS express)时,它并没有指向login.aspx,我做错了什么?简单密码仅供参考。

<location path="~/ManageContacts.aspx">
    <system.web>
      <authorization>
        <deny users="?"/>
        <allow users="admin"/>
      </authorization>

      <authentication mode="Forms">
        <forms loginUrl="~/Account/Login">
          <credentials>
            <user name="admin" password="123456"/>
          </credentials>
        </forms>
      </authentication>

    </system.web>
  </location>

1 个答案:

答案 0 :(得分:0)

请尝试以下代码:

<configuration>
<system.web>
  <authentication mode="Forms">
     <forms loginurl="Account/Login.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" />
  </authentication>
  <authorization>
     <deny users="?" />
  </authorization>
</system.web>
<location path="ManageContacts.aspx">
  <system.web>
     <authorization>
        <deny users="?" />
        <allow users="admin" />
     </authorization>
  </system.web>
</location></configuration>