ASP.NET 2.0 session cookie lost if global.asax is not present
I just wanted to post this after looking in google and not finding anything
If you create an asp.net 2.0 project, you will find that it does not save
the session cookie unless you add a global.asax file to the project (in 2.0
there is not one by default).
More specifically, you must handle the Session_Start event in order for
sessions to be persisted. I checked this by creating a page with two
controls: a text box and a button. The Page_Load for the page has
"TextBox1.Text = Session.SessionID;" in it. You will notice a different
session id is generated each time you click the button. This behavior is not
expected. The SessionID should be the same for each postback.
The behavior stops if you add a Global.asax file to the project.
You were right as soon as I created a global.asax in my project bang! Session works straight away. Thanks for the tip.
|All times are GMT. The time now is 02:50 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.