Unfortunately, I do not know that you will find any way around this restriction. Each time you build your project, you will start restarting the web application. Even if you use a persistent store to store sessions, you will lose the session cookie set in your browser.
You can add the “remember me” function to your application. You need to do a small reevaluation to save current user authentication information in a data warehouse that is less volatile than the state of an ASP.NET session. In addition, you would store an index of this information in a cookie, which would be more robust than a session cookie.
This is the best I can come up with, or at least the best I can come up with without any significant extensions to the .NET security providers. However, take it with salt - I have never tried to solve this problem before, and I hardly consider myself an expert in all ASP.NET related sessions.
source share