And*_*rey 9 asp.net forms-authentication
我的ASP.NET Forms 4.0站点正在运行表单身份验证.默认情况下,未授权用户被拒绝,然后我允许访问某些页面.我在访问默认网址时遇到问题:http:/example.com.我在web.config中有这个条目,它定义了默认页面:
<defaultDocument>
<files>
<clear/>
<add value="default.aspx" />
</files>
</defaultDocument>
Run Code Online (Sandbox Code Playgroud)
我有这个位置覆盖:
<location path="default.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
当我转到完整网址时,它工作正常:http://example.com/default.aspx,但如果我访问http://example.com,则会重定向到登录页面
有什么想法我做错了什么?
And*_*rey 11
我刚刚在答案中(由Dmitry发现)在SO中找到类似问题的答案:表单身份验证忽略默认文档:
在Global.asax中,方法:Application_BeginRequest,放置以下内容:
if (Request.AppRelativeCurrentExecutionFilePath == "~/")
HttpContext.Current.RewritePath("default.aspx");
Run Code Online (Sandbox Code Playgroud)
像魅力一样工作!