For years I've been able to make minor tweaks to web projects and yet maintain sessions. I would often times tweak an ASPX, CSS, or master page, then save and reload in the browser, review the change, lather, rinse, repeat.
For the last year or so I've noticed that now doing that same procedure will reset my session. I initially suspected that it was related to projects that were migrated from 1.0/1.1 to 2.0 Frameworks, but it's even happening on fresh 2.0 and 4.0 projects.
I've migrated machines a few times and the symptoms seem to follow the individual projects that are shared amongst my coworkers through TFS. Our machines are not managed by GPO and we all work from home on independant networks. We also have seen this with
C# and VB. I always get the terms mixed up, but most all of the projects we have are the kind that compile to DLLs in the /bin directory and then deploy as a package (versus compile on demand).
I feel like I've googled like crazy looking for anything to grasp at and I'm running out of ideas of what to search for. Any ideas? Any information I can provide?
When using the default SessionState Mode "InProc", you session will be lost when the application pool recycles. Therer are many reasons why this could happen, but also when you change aspx files:
ASP.NET depends on File Change Notifications (FCN) to see if the application has been updated. Depending on the change the application pool will recycle. If you or your application is adding and removing directories to the application folder, then you will
be restarting your application pool every time, so be careful with those temporary files.
Altering the following files will also trigger an immediate restart of the application pool:
• web.config
• machine.config
• global.asax
• Anything in the bin directory or it's sub-directories
Updating the .aspx files, etc. causing a recompile will eventually trigger a restart of the application pool as well. There is a property of the compilation element under system.web that is called numRecompilesBeforeAppRestart. The default value is 20. This
means that after 20 recompiles the application pool will recycle.
I searched the solution for "InProc" and "numRecompilesBeforeAppRestart" - no occurances at all, so I assume the default values are being used. I also tried using ProcMon to see if saving a file triggers another file to be created/modified but nothing found
there either. I'm guessing FCN must work in-memory?
hans_v
Updating the .aspx files, etc. causing a recompile will eventually trigger a restart of the application pool as well.
Does this apply to projects where the code is compiled to a DLL in the bin directory also vs being compiled on the fly??
hans_v
There is a property of the compilation element under system.web that is called numRecompilesBeforeAppRestart. The default value is 20. This means that after 20 recompiles the application pool will recycle.
In the past when I've been able to save and refresh ASPX/CSS files without losing session. Now my session resets on nearly every edit of a ASPX/CSS file.
In the past when I've been able to save and refresh ASPX/CSS files without losing session. Now my session resets on nearly every edit of a ASPX/CSS file.
CSS files are certainly not causing Application restarts. Are you sure you session are only lost when you change files, or are theu lost when you don't change files at all? There are many other reasons why the application pool recycles
CSS files are certainly not causing Application restarts. Are you sure you session are only lost when you change files, or are theu lost when you don't change files at all? There are many other reasons why the application pool recycles
Just to be sure, I went and tried again. Started the site, logged in on the site, flipped back to Visual Studio and altered a .CSS file, then went back to the site and clicked a link, which immediately showed me a login page again.
I've also considered that maybe this is a matter of Forms Authentication working with FCN and causing the reset? I've also considered that maybe the session is still valid and just showing the login page erroneously, however with more examination it appears
the session is definately reset.
If there are no changed files, the session seems to maintain itself for quite a while. I can go off on a tangent, then pop back and continue browsing the site with no problems at all. Make one change and *poof* it resets.
I don't know why the application pool recycles. But to persist the session even if the application pool recycles, you can change to another SessionState Mode
I have a similar problem, have you managed to solve it? I suspect it has something to do with VS 2012 as when a coworker installed it he immediately started having the same issue. He went back to a restore point before installing it and poof problem was
gone.
jamesnearn
Member
9 Points
8 Posts
Session resets on ASPX and CSS file changes with WebForms
May 21, 2012 06:43 PM|LINK
For years I've been able to make minor tweaks to web projects and yet maintain sessions. I would often times tweak an ASPX, CSS, or master page, then save and reload in the browser, review the change, lather, rinse, repeat.
For the last year or so I've noticed that now doing that same procedure will reset my session. I initially suspected that it was related to projects that were migrated from 1.0/1.1 to 2.0 Frameworks, but it's even happening on fresh 2.0 and 4.0 projects. I've migrated machines a few times and the symptoms seem to follow the individual projects that are shared amongst my coworkers through TFS. Our machines are not managed by GPO and we all work from home on independant networks. We also have seen this with C# and VB. I always get the terms mixed up, but most all of the projects we have are the kind that compile to DLLs in the /bin directory and then deploy as a package (versus compile on demand).
I feel like I've googled like crazy looking for anything to grasp at and I'm running out of ideas of what to search for. Any ideas? Any information I can provide?
Thanks,
James
Michigan, USA
hans_v
All-Star
35998 Points
6551 Posts
Re: Session resets on ASPX and CSS file changes with WebForms
May 21, 2012 06:54 PM|LINK
When using the default SessionState Mode "InProc", you session will be lost when the application pool recycles. Therer are many reasons why this could happen, but also when you change aspx files:
ASP.NET depends on File Change Notifications (FCN) to see if the application has been updated. Depending on the change the application pool will recycle. If you or your application is adding and removing directories to the application folder, then you will be restarting your application pool every time, so be careful with those temporary files.
Altering the following files will also trigger an immediate restart of the application pool:
• web.config
• machine.config
• global.asax
• Anything in the bin directory or it's sub-directories
Updating the .aspx files, etc. causing a recompile will eventually trigger a restart of the application pool as well. There is a property of the compilation element under system.web that is called numRecompilesBeforeAppRestart. The default value is 20. This means that after 20 recompiles the application pool will recycle.
jamesnearn
Member
9 Points
8 Posts
Re: Session resets on ASPX and CSS file changes with WebForms
May 21, 2012 07:32 PM|LINK
Thank you for the quick reply :)
I searched the solution for "InProc" and "numRecompilesBeforeAppRestart" - no occurances at all, so I assume the default values are being used. I also tried using ProcMon to see if saving a file triggers another file to be created/modified but nothing found there either. I'm guessing FCN must work in-memory?
Does this apply to projects where the code is compiled to a DLL in the bin directory also vs being compiled on the fly??
In the past when I've been able to save and refresh ASPX/CSS files without losing session. Now my session resets on nearly every edit of a ASPX/CSS file.
hans_v
All-Star
35998 Points
6551 Posts
Re: Session resets on ASPX and CSS file changes with WebForms
May 21, 2012 08:40 PM|LINK
Yes
http://msdn.microsoft.com/en-us/library/ms366723.aspx
CSS files are certainly not causing Application restarts. Are you sure you session are only lost when you change files, or are theu lost when you don't change files at all? There are many other reasons why the application pool recycles
http://blogs.msdn.com/b/johan/archive/2007/05/16/common-reasons-why-your-application-pool-may-unexpectedly-recycle.aspx
jamesnearn
Member
9 Points
8 Posts
Re: Session resets on ASPX and CSS file changes with WebForms
May 22, 2012 02:36 PM|LINK
Just to be sure, I went and tried again. Started the site, logged in on the site, flipped back to Visual Studio and altered a .CSS file, then went back to the site and clicked a link, which immediately showed me a login page again.
I've also considered that maybe this is a matter of Forms Authentication working with FCN and causing the reset? I've also considered that maybe the session is still valid and just showing the login page erroneously, however with more examination it appears the session is definately reset.
If there are no changed files, the session seems to maintain itself for quite a while. I can go off on a tangent, then pop back and continue browsing the site with no problems at all. Make one change and *poof* it resets.
hans_v
All-Star
35998 Points
6551 Posts
Re: Session resets on ASPX and CSS file changes with WebForms
May 22, 2012 02:57 PM|LINK
I don't know why the application pool recycles. But to persist the session even if the application pool recycles, you can change to another SessionState Mode
http://msdn.microsoft.com/en-us/library/ms178586.aspx
Jan Hudecek
Member
2 Points
1 Post
Re: Session resets on ASPX and CSS file changes with WebForms
Oct 01, 2012 01:27 PM|LINK
Hi James,
I have a similar problem, have you managed to solve it? I suspect it has something to do with VS 2012 as when a coworker installed it he immediately started having the same issue. He went back to a restore point before installing it and poof problem was gone.
Jan
element
Member
4 Points
2 Posts
Re: Session resets on ASPX and CSS file changes with WebForms
Nov 14, 2012 03:19 PM|LINK
Having the same issue. Tried a bunch of stuff, but still no luck....
element
Member
4 Points
2 Posts
Re: Session resets on ASPX and CSS file changes with WebForms
Nov 29, 2012 02:40 PM|LINK
In my case what's happening is the Session_End is called when a save in any file happens (css, aspx, etc..)
In my Session_End, obvisouly I'm killing all my sessions.
The workaround that works for me is simply adding an if statement around the code that kills the sessions:
If CBool(AppSettings("Debug")) = False Then Session.RemoveAll() Session.Abandon() End If