2016-05-16 33 views
1

今天我有一个真正糟糕的WebForms日!WebForms表单身份验证:成功登录并重定向后Request.IsAuthenticated = false

我有一个使用Forms Authentication的成熟WebForms Web应用程序。由于某种未知的原因,我的应用程序已经开始显示Request.IsAuthenticated(在Global.asaxApplication_BeginRequest功能),尽管进入登录页面,登录成功,并呼吁FormsAuthentication.RedirectFromLoginPage()

我只是不能解决出了什么问题。这是我所做的检查。我希望有人可能会指出一些我没有到过这里:

  1. web.config认证部分如下:

    <authentication mode="Forms"> 
        <forms loginUrl="~/Login" timeout="120" cookieless="UseCookies" defaultUrl="~/ExitPoint.aspx?Page=Home" /> 
    </authentication> 
    
  2. web.config授权部分如下:

    <authorization> 
        <deny users="?" /> 
        <allow users="*" /> 
    </authorization> 
    
  3. 对于如登录/注销页面我有:

    <location path="Login"> 
        <system.web> 
         <authorization> 
          <allow users="*" /> 
         </authorization> 
        </system.web> 
    </location> 
    
  4. 当登录时,我有了突破,并逐步完成了身份验证过程。这结束了与:

    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.asaxApplication_BeginRequest()方法Request.IsAuthenticated值输出 “假”(布尔)

  • 我还需要检查什么以查看可能会发生什么错误? THanks

    回答

    1

    我认为这正是预期的。在webforms请求流水线中,AuthenticateRequest事件在BeginRequest事件之后引发,因此请求在BeginRequest事件中尚未通过身份验证才有意义。

    关于流水线的描述参见(例如)here。或者只是谷歌为asp net webforms request pipeline,你会发现很多链接...

    从页部分副本我挂:

    1. 验证请求,该检查由浏览器发送的信息,并确定它是否包含潜在的恶意标记。有关更多信息,请参阅验证请求和脚本利用漏洞概述。
    2. 如果在Web.config文件的UrlMappingsSection部分中配置了任何URL,请执行URL映射。
    3. 引发BeginRequest事件。
    4. 引发AuthenticateRequest事件。
    5. 提高PostAuthenticateRequest事件。
    6. 提高AuthorizeRequest事件。
    7. 引发PostAuthorizeRequest事件。
    8. ...
    +0

    谢谢。我可以发誓'Request.IsAuthenticated'在'Begin_Request'处理程序中显示为true(一旦登录),但是根据您提供的证据和我得到的实际效果,我一定是在欺骗自己!谢谢。 –

    相关问题