Skip to content

Instantly share code, notes, and snippets.

@sjwaight
Created November 17, 2013 02:34
Show Gist options
  • Save sjwaight/7508374 to your computer and use it in GitHub Desktop.
Save sjwaight/7508374 to your computer and use it in GitHub Desktop.
Sample web.config for a basic forms based authentication web application that is using membership and role providers.
<?xml version="1.0"?>
<configuration>
<appSettings />
<connectionStrings>
<!-- you'll need to change this to match your server - the one below is using the default local instance with Windows Auth. -->
<add name="aspnetmembers" connectionString="server=.;initial catalog=AuthDemoApp;Integrated Security=SSPI"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
<authentication mode="Forms">
<forms loginUrl="Login.aspx" defaultUrl="~/Secured/Default.aspx" requireSSL="true" />
</authentication>
<membership defaultProvider="SqlProvider">
<providers>
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="aspnetmembers"
applicationName="AuthDemoApp"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0" />
</providers>
</membership>
<roleManager defaultProvider="SqlProvider"
enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
cookieTimeout="30"
cookiePath="/"
cookieRequireSSL="true"
cookieSlidingExpiration="true"
cookieProtection="All">
<providers>
<add name="SqlProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="aspnetmembers"
applicationName="AuthDemoApp" />
</providers>
</roleManager>
</system.web>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment