The ASP. NET Session always expires. Later I found that the Session will be lost due to directory deletion and rename operations.
If you find that the session is suddenly lost for no reason, and when you carefully check the code and eliminate the possibility of other general loss, you may be close to a crash like me ~!
Later I found the problem was that I used code to create a temporary directory and then deleted the temporary directory.
Now I want to share with you the hope that it will be useful to friends who encounter similar nails ..
To put it bluntly, the essence of ASP. NET Session expiration is that the application restarts!
When will the application automatically restart?
That is to say, asp.net will monitor the application directory. Once any monitored action occurs, such as modifying the config or renaming the directory, the application will automatically restart.
Of course, your session will be lost.
If this operation cannot be avoided, for example, renaming a directory), here we can store the information or store it in the database with cookies;
Note: In addition to the English conditions listed above. Deletion of directories will definitely cause ASP. NET Session to expire. Asp.net's internal mechanism treats a directory a bit like a miser. It keeps a directory and you don't want to add it to it). Once you create it, it will monitor the directory, if you want to delete or rename its Directory), it restarts ..
- Summary of Solutions to ASP. NET Session Timeout
- Cause and solution of ASP. NET Session loss
- ASP. NET code hidden files
- Introduction to ASP. net mvc Framework
- Introduction to MvcAjaxPanel in ASP. NET MVC