Session loss after migrating to ASP. NET 2.0

Source: Internet
Author: User

The HTTPOnly attribute has been added to the session cookie generated by ASP. NET 2.0. this value is hardcoded and cannot be changed via a setting in the application. while this is already ented as a breaking change in the breaking changes document (linked below), it's not clear the types of symptoms you will see in your application, nor is the fix clearly stated.

void application_endrequest (Object sender, eventargs e)
{< br> If (response. cookies. count> 0)
{< br> foreach (string s in response. cookies. allkeys)
{< br> If (S = formsauthentication. formscookiename | S. tolower () = "Asp.net _ sessionid")
{< br> response. cookies [s]. HTTPOnly = false;
}< BR >}

You cocould also roll this into a custom httpmodule to apply it when SS multiple applications if necessary.

Link to breaking changes document:
Http://msdn2.microsoft.com/en-us/netframework/aa497240.aspx
Http://msdn.microsoft.com/netframework/programming/breakingchanges/runtime/aspnet.aspx

Link to HTTPOnly attribute:
Http://msdn2.microsoft.com/en-us/library/system.web.httpcookie.httponly.aspx

Link to httpmodule documentation:
Http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/cpguide/html/cpconhttpmodules. asp

Special thanks to Shai Zohar for helping isolate the issue as well as testing the above solution.

Filed under: ASP. NET

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.