<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>ASP.NET Universal Providers Readme</title>
<style type="text/css">
body{
margin-left:1in;
margin-top:.75in;
margin-right:1.7in;
font-family:calibri;
font-size:11pt;
line-height:1.15em;
background-color:white;
}
h1{
margin-left:-.2in;
font-family:Arial, Verdana, sans-serif;
font-size:20pt;
}
h2{
margin-left:-.2in;
margin-top:1.8em;
font-family:Arial, Verdana, sans-serif;
font-size:16pt;
}
h3{
margin-left:-.2in;
font-family:Verdana, sans-serif;
font-size:13.5pt;
}
table{
border:thin gray groove;
}
thead{
background-color:black;
color:white;
font-weight:bold;
text-align:center;
}
td{
border:1px solid black;
}
p.indent1{
margin-left:.25in;
}
code{
font-family:"Courier New";
font-size:10pt;
color:#006600;
}
pre{
font-family:"Courier New";
font-size:10pt;
padding:8px;
color:#006600;
}
span.highlight{
background-color:Yellow;
}
</style>
</head>
<body>
<h1>ASP.NET Universal Providers</h1>
<p>Last update: 15 August 2012</p>
<p>The
<a href="http://msdn.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider.aspx">SqlMembershipProvider</a>,
<a href="http://msdn.microsoft.com/en-us/library/system.web.security.sqlroleprovider.aspx">SqlRoleProvider</a>,
<a href="http://msdn.microsoft.com/en-us/library/system.web.profile.sqlprofileprovider.aspx">SqlProfileProvider</a> classes that shipped in ASP.NET through version 4 support only Microsoft SQL Server and Microsoft SQL Server Express. They do not support newer offerings such as
<a href="http://msdn.microsoft.com/en-us/library/ee336241.aspx">Microsoft SQL Azure</a> and
<a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=033cfb76-5382-44fb-bc7e-b3c8174832e2">Microsoft SQL Server Compact</a>. </p>
<p>ASP.NET Universal Providers have been created in order to extend support to all editions of SQL Server 2005 and later and to SQL Azure. If you use these providers to develop your application, the application will be ready for cloud environments like Azure.</p>
<p>Other than supporting additional storage options, the providers work like the existing SQL-based providers. Except as noted below, using ASP.NET Universal Providers requires no change in any of your applications.</p>
<ul>
<li><a href="#Installing_and_Configuring_ASP.NET_Unive">Installing and
Configuring ASP.NET Universal Providers</a></li>
<li><a href="#Selecting_a_Data_Store">Selecting a Data Store</a></li>
<li><a href="#Storing_Data_in_Session_State_using_ASP">Storing Data in
Session State using ASP.NET Universal Providers</a></li>
<li><a href="#Deploying_to_a_Cloud_Environment">Deploying to a Cloud
Environment</a></li>
<li><a href="#Known_Issues">Known Issues</a></li>
<li><a href="#Additional_Resources">Additional Resources</a></li>
<li><a href="#Disclaimer">Disclaimer</a><br />
</li>
</ul>
<h2><a name="Installing_and_Configuring_ASP.NET_Unive">Installing and Configuring ASP.NET Universal Providers</a></h2>
<p>To install ASP.NET Universal Providers, you use a NuGet package, which installs all required files (including this documentation). The NuGet package automatically enables the new providers when it is installed. By default, the NuGet package configures provider to use SQL Server Express. To use SQL Server Compact or SQL Azure, you must change the connection string for the provider, as explained
<a href="#Selecting_a_Data_Store">later in this document</a>.</p>
<p>To enable the providers, the NuGet package adds configuration entries in the
<em>web.config</em> file. The configuration for these providers is the same as the existing
<code>SqlMembershipProvider</code> class, but the <code>type</code> parameter is set to the type of the new providers, as shown in the following table:</p>
<table>
<thead>
<td>SQL Provider Types</td>
<td>Equivalent Type for Universal Providers</td>
</thead>
<tr>
<td ><code>System.Web.Security.SqlMembershipProvider</code></td>
<td ><code>System.Web.Providers.DefaultMembershipProvider</code></td>
</tr>
<tr>
<td><code>System.Web.Profile.SqlProfileProvider</code></td>
<td><code>System.Web.Providers.DefaultProfileProvider</code></td>
</tr>
<tr>
<td><code>System.Web.Security.SqlRoleProvider</code></td>
<td><code>System.Web.Providers.DefaultRoleProvider</code></td>
</tr>
<tr>
<td>(Built into default provider)</td>
<td><code>System.Web.Providers.DefaultSessionStateProvider</code></td>
</tr>
</table>
<p>In the <em>web.config</em> file, the configuration looks like the following example (the connection string has been wrapped for readability). The differences from the configuration for older SQL-based providers are highlighted. Notice that a section has been added to define custom session-state handling using a custom provider, as described later under
<a href="#Storing_Data_in_Session_State_using_ASP">Storing Data in Session State using ASP.NET Universal Providers</a>.</p>
<pre><configuration>
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnetdb;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<membership <span class="highlight">defaultProvider="DefaultMembershipProvider"</span>>
<providers>
<clear />
<add name="DefaultMembershipProvider"
<span class="highlight">type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
</span> connectionStringName="DefaultConnection"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile <span class="highlight">defaultProvider="DefaultProfileProvider"</span>>
<providers>
<clear />
<add name="DefaultProfileProvider"
<span class="highlight">type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
</span> connectionStringName="DefaultConnection"
applicationName="/" />
</providers>
</profile>
<roleManager <span class="highlight">defaultProvider="DefaultRoleProvider"</span> enabled="false">
<providers>
<clear />
<add name="DefaultRoleProvider"
<span class="highlight">type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
</span> connectionStringName="DefaultConnection"
applicationName="/" />
</providers>
</roleManager>
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider"
<span class="highlight">type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
</span> connectionStringName="DefaultConnection"
applicationName="/" />
</p