Autostart ASP.NET site during development

When developing an ASP.NET site, can I configure automatic login?

For example, every time I create a site and launch it, I need to log in again. I do not want to completely disable the protection, but I would like to automate the process of logging in while I work on this site.

+7
source share
3 answers

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.

+4
source

Use Integrated Windows Authentication for your debugging and Forms Authentication for your production code?

If this is an option, you can have multiple web.config files for different environments - see the question How do you handle multiple web.config files for multiple environments? .

We are also exploring the presence of several web.configs in different environments. One of the ideas we have (so that we do not study in detail) is to use T4 code generation (part of Visual Studio) to generate web.config as part of the build process.

+1
source

This may or may not work, considering how complicated your security requirements are, but you may have an alternative login page that uses built-in (NTLM or Kerberos) authentication and your Windows credentials will be automatically transferred to the site.

0
source

All Articles