Just open your browser and Ctrl + F5 after changing and / or recompiling in Visual Studio. This will save the authentication cookie.
Another possibility is to set up an automatic login page in which you will check whether you are in debug mode and force Login using FormsAuthentication.RedirectFromLoginPage("someusername", false); . Then you can tell Visual Studio to always launch the website at this URL:
protected void Page_Load(object sender, EventArgs e) { #if DEBUG FormsAuthentication.RedirectFromLoginPage("someusername", false); #endif }
Ideally, this page should be excluded from the build process and never sent.
As pointed out in the @Mufasa comment section, if your site uses a session, you may need to use from process mode (StateServer or SqlServer) instead of InProc , because when you recompile the application domain, it will be rebooted and everything will be saved in memory.
Darin Dimitrov
source share