今天我有一个真正糟糕的WebForms日!WebForms表单身份验证:成功登录并重定向后Request.IsAuthenticated = false
我有一个使用Forms Authentication的成熟WebForms Web应用程序。由于某种未知的原因,我的应用程序已经开始显示Request.IsAuthenticated
(在Global.asax
的Application_BeginRequest
功能),尽管进入登录页面,登录成功,并呼吁FormsAuthentication.RedirectFromLoginPage()
。
我只是不能解决出了什么问题。这是我所做的检查。我希望有人可能会指出一些我没有到过这里:
的
web.config
认证部分如下:<authentication mode="Forms"> <forms loginUrl="~/Login" timeout="120" cookieless="UseCookies" defaultUrl="~/ExitPoint.aspx?Page=Home" /> </authentication>
的
web.config
授权部分如下:<authorization> <deny users="?" /> <allow users="*" /> </authorization>
对于如登录/注销页面我有:
<location path="Login"> <system.web> <authorization> <allow users="*" /> </authorization> </system.web> </location>
当登录时,我有了突破,并逐步完成了身份验证过程。这结束了与:
FormsAuthentication.RedirectFromLoginPage(userID, createPersistentCookie: true); // Includes call to SetAuthCookie()
,其中用户ID是 “768” 字符串值。
加密的会话cookie出现在浏览器上的下一个请求:
Name=.ASPXAUTH Value=FFC592..... Expires=2016-05-16T15:41:58.817Z (basically "now"+1 hour) Path=/ Domain=localhost HTTP=Yes Secure=(blank i.e. No)
登录在
Global.asax
Application_BeginRequest()
方法Request.IsAuthenticated
值输出 “假”(布尔)
我还需要检查什么以查看可能会发生什么错误? THanks
谢谢。我可以发誓'Request.IsAuthenticated'在'Begin_Request'处理程序中显示为true(一旦登录),但是根据您提供的证据和我得到的实际效果,我一定是在欺骗自己!谢谢。 –