Skip to content

Latest commit

 

History

History
88 lines (77 loc) · 4.79 KB

dn433232.md

File metadata and controls

88 lines (77 loc) · 4.79 KB

title: Universal Providers enable Cloud-based Storage in Open Ria Services TOCTitle: Universal Providers enable Cloud-based Storage in Open Ria Services ms:assetid: 95010981-2ec7-411f-8fca-2290595d5375 ms:mtpsurl: https://msdn.microsoft.com/en-us/library/Dn433232(v=VS.91) ms:contentKeyID: 56562007 ms.date: 08/19/2013 mtps_version: v=VS.91

Universal Providers enable Cloud-based Storage in Open Ria Services

[ This document was written for WCF Services Version 1 Service Pack 2 and might not be up to date
Please see Release Notes or Changelog for a list of changes since WCF RIA Services ]

To use SQL Azure cloud storage with a Open Ria Services application, you must install the ASP.NET Universal Providers that add support for Session, Membership, Roles and Profile in ASP.NET 4. These providers support all editions of SQL Server 2005 and later, including SQL Azure and SQL Server Compact editions. The Universal Providers are installed with Visual Studio 2012, but need to be installed separately using the Nuget Package Manager for relevant projects in Visual Studio. They are contained in the System.Web.Provider.dll and Open Ria Services applications that use them must make reference to this assembly.

Other than supporting the additional storage options, the providers work just like the existing SQL-based providers. Using the Universal "Default Profile Providers" consists of setting the right connection strings in the application. By default, the connection string is set to use a SQL Server Express database, as in the following example.

<configuration>
   <connectionStrings>
      <add name="DefaultConnection" 
      connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\aspnet.mdf;Initial Catalog=aspnet;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
   </connectionStrings>
   <system.web>
      <profile defaultProvider="DefaultProfileProvider" >
         <providers>
            <add name="DefaultProfileProvider" 
         type="System.Web.Providers.DefaultProfileProvider" 
   connectionStringName="DefaultConnection" 
applicationName="/"/>
         </providers>
      </profile>
      <membership defaultProvider="DefaultMembershipProvider">
         <providers>
            <add name="DefaultMembershipProvider" 
            type="System.Web.Providers.DefaultMembershipProvider" 
            connectionStringName="DefaultConnection" 
            enablePasswordRetrieval="false" 
            enablePasswordReset="true" 
            requiresQuestionAndAnswer="false" 
requiresUniqueEmail="false"
   maxInvalidPasswordAttempts="5" 
      minRequiredPasswordLength="6" 
minRequiredNonalphanumericCharacters="0" 
passwordAttemptWindow="10"
   applicationName="/" />
         </providers>
      </membership>
      <roleManager defaultProvider="DefaultRoleProvider">
         <providers>
      <add name="DefaultRoleProvider" 
            type="System.Web.Providers.DefaultRoleProvider"
connectionStringName="DefaultConnection" 
applicationName="/" />
         </providers>
      </roleManager>
      <sessionState mode="Custom" customProvider="DefaultSessionProvider">
         <providers>
            <add name="DefaultSessionProvider" 
         type="System.Web.Providers.DefaultSessionStateProvider" 
         connectionStringName="DefaultConnection" 
      applicationName="/"/>
         </providers>
      </sessionState>
   </system.web>
</configuration>

If you want to use SQL Azure, change the connection string as in this example, which has been wrapped for readability.

<connectionStrings>
   <add name="Sql_Azure"
      connectionString="data source=myDNSName;
      Initial Catalog=myDatabase;
      User ID=myUserName;
      Password=myPassword;
      Encrypt=true;
      Trusted_Connection=false;
      MultipleActiveResultSets=True" 
      providerName="System.Data.SqlClient"/>
<connectionStrings>

No code changes are required in addition to these changes in the configuration strings.

Nuget Package Manager in Visual Studio

To install the Universal Providers in an application being developed with Visual Studio, right-click on the References folder of the client application in Solution Explorer and select the Manage NuGet Packages option. Find the Microsoft ASP.NET Universal Providers package, select it, and then click on the Install button that appears. Confirm that a reference has been provided to the System.Web.Provider assembly.