Skip to content

Instantly share code, notes, and snippets.

@jinweijie
Created December 12, 2013 06:14
Show Gist options
  • Select an option

  • Save jinweijie/7923887 to your computer and use it in GitHub Desktop.

Select an option

Save jinweijie/7923887 to your computer and use it in GitHub Desktop.
Dynamic modify LoginUrl for FormsAuthentication
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration("/YourSite");
// Get the external Authentication section.
AuthenticationSection authenticationSection =
(AuthenticationSection)configuration.GetSection(
"system.web/authentication");
// Get the external Forms section .
FormsAuthenticationConfiguration formsAuthentication =
authenticationSection.Forms;
formsAuthentication.LoginUrl = "http://google.com";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment