While developing an ASP.NET site, is the a way to setup automatic login?
For example, each time I build the site and run it, I have to login again. I don't want to disable security entirely, but I would like to automate the process of logging in while I'm working on the site.
Just keep your browser open and Ctrl+F5 after you modify and/or recompile in Visual Studio. This will keep the authentication cookie.
Another possibility is to setup an automatic login page in which you would test whether you are in Debug mode and force a Login by using FormsAuthentication.RedirectFromLoginPage("someusername", false);
. Then you could instruct Visual Studio to always run the web site 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 shipped.
As pointed out in the comments section by @Mufasa if your site uses Session you might need to use out of process mode (StateServer or SqlServer) instead of InProc
because when you recompile the application domain will be reloaded and everything stored in memory lost.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With