Home > Mobile >  Session variables getting lost when navigating to a different controller (& AJAX requests), however
Session variables getting lost when navigating to a different controller (& AJAX requests), however

Time:04-21

This question is about an issue we are facing with a .net framework based MVC app that uses windows authentication. The variables set during Session_Start seems to be just fine and available throughout, but any session variable set after the fact seems to be lost. In the output below, first line is where we set a session variable. The exception is when I am trying to access it in a different page. However if you notice other session variables set during Session_Start are still available. This is issue 1.

Current session value (home): zero
---
(different page)
System.NullReferenceException: Object reference not set to an instance of an object.
   at ---removed---
   at ---removed---
Id (from session): 0
Name (from session): Admin
Email (from session): [email protected]

We explored further and it also seems like AJAX requests are creating a whole new session. This is issue 2. We have tried a number of things - update the $.ajax call to xhrfields/withCrdentials, tried setting an AutoRedirectMode using the FriendlyUrls package, tried ignoring a few routes suggested, etc. But nothing helps. So any pointers regarding this would be appreciated.

Thanks!

CodePudding user response:

We found the issue. Looks like some process (most likely the anti-virus) is messing with the bin directory causing the application to be restarted again and again. So we added the fcnMode attribute to the httpRuntime element and set it to Disabled so as to disable the behavior for now.

  • Related