我想在我的网站上使用FormsAuthentication来保护我的静态文件,所以我按照这里的说明http://learn.iis.net/page.aspx/244/how-to-take-advantage-of-the -iis7-integrated-pipeline /标题为"为整个应用程序启用表单身份验证".
现在,当我尝试通过直接访问http://www.mysite.com访问该网站时,我被重定向到http://www.mysite.com/Login.aspx?ReturnUrl=%2f而不是使用我的我已经设置了DefaultDocument.我可以通过访问http://www.mysite.com/Home.aspx来查看我的默认文档,没有任何问题,因为它设置为允许匿名访问.
我需要添加到我的web.config文件中以使iis7允许匿名访问根目录吗?我尝试添加匿名访问但没有这样的运气.
任何帮助将非常感激.
Home和Login表单都允许匿名.
<location path="Home.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Login.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Run Code Online (Sandbox Code Playgroud)
登录表单设置为loginUrl
<authentication mode="Forms">
<forms protection="All" loginUrl="Login.aspx">
</forms>
</authentication>
Run Code Online (Sandbox Code Playgroud)
默认文档设置为Home.aspx
<defaultDocument>
<files>
<add value="Home.aspx" />
</files>
</defaultDocument>
Run Code Online (Sandbox Code Playgroud)
我没有删除任何iis7默认文档.但是,Home.aspx是优先考虑的问题.