ASP.NET 2.0 session cookie lost if global.asax is not present

G

Guest

I just wanted to post this after looking in google and not finding anything
about it:


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.
 
Joined
Feb 26, 2008
Messages
1
Reaction score
0
Problem Solved...

You were right as soon as I created a global.asax in my project bang! Session works straight away. Thanks for the tip.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top