我正在尝试在 IIS 7 中设置表单身份验证。当用户尝试点击网站上的任何 url 时,他们会被重定向到登录页面,但登录后他们不会离开页面。如果我启用匿名日志记录,那么登录页面工作正常,页面被重定向到登录页面。
这是web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="LandingPage" value="/home/default.htm" />
</appSettings>
<system.web>
<compilation debug="false" />
<authentication mode="Forms">
<forms loginUrl="/login/login.aspx" timeout="60" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly">
<remove statusCode="401" subStatusCode="-1" />
<error statusCode="401" prefixLanguageFilePath="" path="/login/login.aspx" responseMode="ExecuteURL" />
</httpErrors>
<defaultDocument enabled="false">
<files>
<remove value="iisstart.htm" />
<remove value="index.htm" />
<remove value="Default.htm" />
<remove value="Default.asp" />
<remove value="default.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
<modules>
<remove name="FormsAuthentication" />
<remove name="DefaultAuthentication" />
<add name="DefaultAuthentication" type="System.Web.Security.DefaultAuthenticationModule" preCondition="" />
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" preCondition="" />
</modules>
</system.webServer>
</configuration>
我已按照http://technet.microsoft.com/en-us/library/cc753252(v=ws.10).aspx和http://www.iis.net/learn/application-frameworks/building中的说明进行操作-and-running-aspnet-applications/using-aspnet-forms-authentication但我一定错过了什么。
谢谢。
编辑:添加了建议的元素,但同样的事情发生了。提琴手展示了这一点:
1 302 HTTP localhost / 148 iexplore:14040
2 200 HTTP localhost /login/login.aspx?ReturnUrl=%2f 4,896 private text/html; charset=utf-8 iexplore:14040
3 304 HTTP localhost /images/newheader.jpg 0 iexplore:14040
4 302 HTTP localhost /login/login.aspx?ReturnUrl=%2f 142 private, no-cache="Set-Cookie" text/html; charset=utf-8 iexplore:14040
5 302 HTTP localhost /home/default.htm 170 iexplore:14040
6 200 HTTP localhost /login/login.aspx?ReturnUrl=%2fhome%2fdefault.htm 4,918 private text/html; charset=utf-8 iexplore:14040
7 304 HTTP localhost /images/newheader.jpg 0 iexplore:14040