gpt4 book ai didi

asp.net - 使用 ASP.Net 表单例份验证允许未经身份验证的用户访问特定页面

转载 作者:行者123 更新时间:2023-12-02 02:21:04 24 4
gpt4 key购买 nike

我正在使用 ASP.Net 表单例份验证。我的 Web.config 看起来像这样。

    <authentication mode="Forms">
<forms loginUrl="login.aspx"/>
</authentication>
<authorization>
<deny users="?" />
</authorization>

因此目前每个 aspx 页面都需要身份验证。

我希望允许未经身份验证的用户访问名为special.aspx 的特定页面。我怎样才能做到这一点?

最佳答案

看一下 MS Support 上的示例

<configuration>
<system.web>
<authentication mode="Forms" >
<forms loginUrl="login.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" >
</forms>
</authentication>
<!-- This section denies access to all files in this
application except for those that you have not explicitly
specified by using another setting. -->
<authorization>
<deny users="?" />
</authorization>
</system.web>
<!-- This section gives the unauthenticated
user access to the ThePageThatUnauthenticatedUsersCanVisit.aspx
page only. It is located in the same folder
as this configuration file. -->
<location path="ThePageThatUnauthenticatedUsersCanVisit.aspx">
<system.web>
<authorization>
<allow users ="*" />
</authorization>
</system.web>
</location>
<!-- This section gives the unauthenticated
user access to all of the files that are stored
in the TheDirectoryThatUnauthenticatedUsersCanVisit folder. -->
<location path="TheDirectoryThatUnauthenticatedUsersCanVisit">
<system.web>
<authorization>
<allow users ="*" />
</authorization>
</system.web>
</location>
</configuration>

关于asp.net - 使用 ASP.Net 表单例份验证允许未经身份验证的用户访问特定页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3628445/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com