允许unathenticated用户访问特定的页面使用ASP.Net Forms身份验证的访问 [英] Allow access for unathenticated users to specific page using ASP.Net Forms Authentication

查看:314
本文介绍了允许unathenticated用户访问特定的页面使用ASP.Net Forms身份验证的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表单验证。我的web.config看起来是这样的。

I am using ASP.Net Forms Authentication. My Web.config looks like this.

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

所以目前每一个aspx页面需要验证。

So currently every aspx page requires authentication.

我想允许访问即使未认证用户名为special.aspx特定页面。
我怎样才能做到这一点?

I want to allow access to even unauthenticated users to a specific page named special.aspx. How can I do this?

推荐答案

看看这个例子上 MS支持

<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>

这篇关于允许unathenticated用户访问特定的页面使用ASP.Net Forms身份验证的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆