允许默认页面的匿名访问 [英] Allowing anonymous access to default page

查看:187
本文介绍了允许默认页面的匿名访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP.NET表单4.0站点与窗体身份验证运行。默认情况下未授权用户都被拒绝了,然后我允许访问某些网页。
我有一个问题,允许访问默认的URL:http:/mysite.com。我在web.config中这个条目定义了默认的页面:

My ASP.NET Forms 4.0 site is running with forms authentication. By default unauthorized users are denied, and then I allow access to certain pages. I have a problem allowing access to the default url: http:/mysite.com. I have this entry in web.config that defines default page:

<defaultDocument>
    <files>
        <clear/>
        <add value="default.aspx" />
    </files>
</defaultDocument>

和我有这样的定位越权:

and I have this location override:

<location path="default.aspx">
    <system.web>
        <authorization>
            <allow users="?"/>
        </authorization>
    </system.web>
</location>

它的工作原理确定,当我去的完整URL: http://mysite.com/default.aspx ,但重定向登录页面如果我去 http://mysite.com

It works OK when I go to the full url: http://mysite.com/default.aspx, but redirects to the login page if I go to http://mysite.com

任何想法我做错了?

推荐答案

我刚在响应(德米特里·)在这里的SO类似的问题找到答案:<一href=\"http://stackoverflow.com/questions/3824951/forms-authentication-ignoring-default-document\">Forms验证忽略默认文档:

I just found answer in a response (by Dmitry) to a similar question here in SO: Forms Authentication Ignoring Default Document:

在Global.asax中,方法:的Application_BeginRequest,将以下内容:

In Global.asax, method: Application_BeginRequest, place the following:

if (Request.AppRelativeCurrentExecutionFilePath == "~/")
    HttpContext.Current.RewritePath("default.aspx");

工作就像魅力!

这篇关于允许默认页面的匿名访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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