Making user login persistant with ASP .Net Membership

后端 未结 3 1031
天命终不由人
天命终不由人 2020-12-08 16:29

I have a website that is built in ASP.NET 3.5 & SQL Server 2005, using the sql membership provider, and presumably forms authentication.

Since security needs on

3条回答
  •  一向
    一向 (楼主)
    2020-12-08 16:56

    I finally figured out the last piece of the puzzle. When the app pool of my server was being recycled (configured by the hosting provider), the viewstate encryption key was being auto-re-generated. This meant that even though the cookies were valid & non expired (pre-return visit), when the user returned the encyrption had changed, and the cookie was no longer valid.

    The solution was to manually specify a static validation key. The following link can be used to generate the neccessary web.config tag for this.

    http://www.aspnetresources.com/tools/keycreator.aspx

    UPDATE:

    Here's a more configurable site to generate Machine Key

    Source Tree - Generage attribute

    I realize that this might have a minor security impact, I guess theoritically it's safer to have a changing key in case your key gets brute forced and compromises any data you might be storing in the view state, but you probably shouldn't be storing sensitive information in the viewstate as it's not inherently safe anyway.

    Example:

    
      
        
      
    
    

提交回复
热议问题