Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Why would this happen?Session_Start event in global.asax
fires on each page request on my website.


First time it is working fine,after some time Session_Start event in global.asax
fires on each page request

Why would this happen?


Please help me


Please let me know if you did not understand my question

Thanks,
Chaitanya
Posted
Updated 3-Feb-20 7:46am
v5

# Session_Start: Fired when a new user visits the application Website.

Please go through these links
http://www.techrepublic.com/article/working-with-the-aspnet-globalasax-file/5771721[^]
http://msdn.microsoft.com/en-us/library/ms178473.aspx[^]
 
Share this answer
 
Comments
venkata chaitanya 28-Aug-12 3:36am    
yes i know # Session_Start: Fired when a new user visits the application Website.

But here my problem is first time it is working fine, after one hour if i click on pages in my application the session start event firing for each page request instead of firing only one time.So that my code is executing on each page request of same user
Session start event is fired only when a new session for a user starts. Once “Session_Start” for a user is fired then if the user makes subsequent request to any resource within the application this event is not at all triggered. The event is triggered only when the user’s session expires and then the user tries to access any resource in the application again.
This event can be used when you want to do something when the user visits you site/application for the first time or when his session starts. This event doesn’t get triggered if you are not using sessions which can be disabled in the web.config.

Refer this[^] for more information.


--Amit
 
Share this answer
 
Comments
venkata chaitanya 29-Aug-12 5:20am    
You are right,Unfortunately it is not happening in my site.My site is a static site containing 5 aspx pages.i just want to know how many users visited.so i am saving the count in text file.when new user visited i am increasing the count in session_start event.Some times it is firing 2 times.So that no of users visited count is increased to 2 instead of 1.I dont know why this is happening... :(
venkata chaitanya 29-Aug-12 5:26am    
Yes i tried the same.As i said Session_start event is firing on each page request.
So that count is increasing for each page request.Some times it is firing 2 times (I think due to master page but not sure).
_Amy 29-Aug-12 5:31am    
Then, definitely you are committing mistake somewhere. Cross check your coding and verify with the links coding. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900