Reputation: 1251
I thought the session_start event in the global.asax should only fire the first time I access a page on the web site. But I noticed for in asp.net mvc3 when I go to different paths it runs every time.
Ex.
http://webserver/home/index - runs once here (link 1)
http://webserver/contact/index - runs once here (link 2)
Do I need to configure something so session_start only runs once? I tested this by setting a session variable to current date time and displayed the session variable on the layout page. When I click on linked 1 from above it displayed a time and when I clicked on link 2 from above it displayed a time. Both times were different. Any ideas?
Thank you
Upvotes: 2
Views: 3366
Reputation: 13351
If Session_Start
or Session_End
handlers are not defined in the Global.asax
, a new Session ID is generated for every request, when there is nothing stored in the Session bag.This is what happening in your case
similar, ASP.Net Session_Start always firing
Upvotes: 3