ASP.Net Session_Start always shoots

I got a little confused about the following: I created an asp.net site with some logic in Session_Start () for Global.asx. I expected this to even call only once during a session. However, an event is fired with every request.

When I declare a dummy session object, this fixes the problem. I can also fix this problem by adding <sessionState mode="InProc" /> to web.config. I am using IIS7 and I checked the default value and it is already set to "In Process".

Am I missing something? Is this normal behavior? I expected this event to work even if I do not declare a session object.

+4
source share
3 answers

I think this happens if the browser used does not allow cookies. In addition, if the application pool restarts, the session will be lost.

 <sessionState cookieless="true" /> 

This will solve cookies problems that are not allowed.

+1
source

You should check:

  • Are your web browser cookies enabled?
  • If you want browser cookies to be disabled, you will need to control session state without cookies (this is not very good because the session parameter will be in the query line ...).
  • During Application_Start in your Global.asx, if you do something there, you check to see if it throws an exception that causes your application to crash and end?
  • Do you do anything at any stage after Application_Start and before Session_Start? If this is your case, check the same as the previous point.
+1
source

Source: https://habr.com/ru/post/1338238/


All Articles