WebForms 表单身份验证:成功登录并重定向后 Request.IsAuthenticated=false
WebForms Forms Authentication: Request.IsAuthenticated=false after successful log in and redirect
我今天的 WebForms 真的很糟糕!
我有一个使用表单身份验证的成熟 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>
对于Login/Logout这样的页面我有:
<location path="Login">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
登录时,我设置了断点并逐步完成了身份验证过程。结束时:
FormsAuthentication.RedirectFromLoginPage(userID, createPersistentCookie: true);
// Includes call to SetAuthCookie()
其中 userID 是字符串值“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
值正在输出 "False" (bool)
我还需要检查什么以查看可能出了什么问题?
谢谢
我认为这正是我们所期望的。在 webforms
请求管道中,AuthenticateRequest
事件在 BeginRequest
事件之后引发,因此在 BeginRequest
事件中请求尚未经过身份验证是有道理的。
参见(例如)here 了解管道的描述。或者只是 Google for asp net webforms request pipeline
你会发现很多链接...
我链接到的页面的部分副本:
- 验证请求,检查浏览器发送的信息并确定它是否包含潜在的恶意标记。有关详细信息,请参阅 ValidateRequest 和脚本利用概述。
- 执行 URL 映射,如果在 Web.config 文件的 UrlMappingsSection 部分配置了任何 URL。
- 引发 BeginRequest 事件。
- 引发 AuthenticateRequest 事件。
- 引发 PostAuthenticateRequest 事件。
- 引发 AuthorizeRequest 事件。
- 引发 PostAuthorizeRequest 事件。
- ...
我今天的 WebForms 真的很糟糕!
我有一个使用表单身份验证的成熟 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>
对于Login/Logout这样的页面我有:
<location path="Login"> <system.web> <authorization> <allow users="*" /> </authorization> </system.web> </location>
登录时,我设置了断点并逐步完成了身份验证过程。结束时:
FormsAuthentication.RedirectFromLoginPage(userID, createPersistentCookie: true); // Includes call to SetAuthCookie()
其中 userID 是字符串值“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
值正在输出 "False" (bool)
我还需要检查什么以查看可能出了什么问题? 谢谢
我认为这正是我们所期望的。在 webforms
请求管道中,AuthenticateRequest
事件在 BeginRequest
事件之后引发,因此在 BeginRequest
事件中请求尚未经过身份验证是有道理的。
参见(例如)here 了解管道的描述。或者只是 Google for asp net webforms request pipeline
你会发现很多链接...
我链接到的页面的部分副本:
- 验证请求,检查浏览器发送的信息并确定它是否包含潜在的恶意标记。有关详细信息,请参阅 ValidateRequest 和脚本利用概述。
- 执行 URL 映射,如果在 Web.config 文件的 UrlMappingsSection 部分配置了任何 URL。
- 引发 BeginRequest 事件。
- 引发 AuthenticateRequest 事件。
- 引发 PostAuthenticateRequest 事件。
- 引发 AuthorizeRequest 事件。
- 引发 PostAuthorizeRequest 事件。
- ...