我在登录过程中遇到问题。ASP.NET身份验证问题
有些客户抱怨说他们无法登录。我可以在我们的日志中看到他们的登录成功,并且他们从登录页面重定向到成员区域。但是,不知何故登录未被检测到,并且他们被弹回到登录页面。
我已要求客户检查是否支持cookies(http://www.html-kit.com/tools/cookietester/),但问题仍然存在,即使此测试返回true。
这是怎么了,我实现了登录过程(simplyfied):通过在Page_Load中功能
protected void Login(string email, string password)
{
FormsAuthentication.SignOut();
Guid clientId = /* Validate login by checking email and password, if fails display error otherwise get client id */
FormsAuthentication.SetAuthCookie(clientId.ToString(), true);
HttpContext.Current.Response.Redirect("~/Members.aspx");
}
在成员页面我检查认证:
public static void IsAuthenticated()
{
if (!HttpContext.Current.User.Identity.IsAuthenticated)
{
HttpContext.Current.Response.Redirect("~/Login.aspx", true);
}
}
也许我使用FormsAuthentication完全错误?
我已经问过这个,但还没有能够弄清楚这一点,我会很感激任何帮助。
从我的web.config:
<system.web>
<compilation debug="false">
<assemblies>
...
</assemblies>
</compilation>
<authentication mode="Forms"/>
<sessionState mode="InProc" cookieless="false" timeout="180"/>
<customErrors mode="On"/>
<httpHandlers>
...
</httpHandlers>
<httpModules>
...
</httpModules> </system.web>
你想念登录页面并拒绝所有用户(请参阅我的回答)。 – Michel 2010-06-03 09:03:01
请注意,当前登录过程适用于大多数客户(99%)。 – 2010-06-03 09:19:17