c#匿名用户授权失败



我正在尝试建立一个表单身份验证应用程序,其中所有页面都可以访问经过身份验证的用户,除了登录页面向所有或匿名用户开放。

我设置了web。配置如下:

<system.web>
<authentication mode="Forms">
<forms name=".ADAuthCookie" loginUrl="~/Login.aspx" timeout="3"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
...
</system.web>
....
<location path="Login.aspx">
<system.web>
<authorization>
<allow users="?"/>
<!--  also tried this
<allow users="*"/>
-->
</authorization>
</system.web>
</location>

我还将起始页(在VS 2019)设置为login.aspx。当我运行它时,我仍然得到:

Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
Error message 401.2.: Unauthorized: Logon failed due to server configuration.  Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. 

我通过移动登录解决了这个问题。aspx到一个文件夹(我叫它Account)。我加了一张网。在内容为:

的文件夹中配置
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</configuration>

我删除了"位置";部分来自main web.config。所以它看起来像:

<system.web>
<authentication mode="Forms">
<forms name=".ADAuthCookie" loginUrl="~/Account/Login.aspx" timeout="3"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
....
</system.web>

相关内容

  • 没有找到相关文章

最新更新