Universal ASP.NET Providers??? Getting SQL Azure to handle your Session State


While pulling together this post on the August release of the Windows Azure Tools I noted that the ASP.NET MVC 3 template included “the new universal ASP.Net providers that support SQL Azure”. Which made me pause and think … “What universal ASP.NET Providers?”

Looks like their existence completely passed me by :-)

Scott Hanselman summarised the purpose of the Universal Providers back in June. Simply put they extend Session, Membership, Roles and Profile support to include SQL Compact Edition and SQL Azure. In all other ways they work like the existing SQL-based providers. They are released via a NuGet Package (something else I need to dig into more).

What this means is we now have a supported way of doing session state with SQL Azure, rather than via workarounds (e.g. this one from Wayne)

By default, the NuGet package sets the connection string to use a SQL Server Express database:

"Source=.\SQLEXPRESS;

AttachDbFilename=|DataDirectory|\aspnetdb.mdf;

Initial Catalog=aspnet;

Integrated Security=True;

User Instance=True;

MultipleActiveResultSets=True" 

providerName="System.Data.SqlClient" 

For SQL Azure you simply change to:

“data source=myDNSName;

Initial Catalog=myDatabase;

User ID=myUserName;

Password=myPassword;

Encrypt=true;

Trusted_Connection=false;

MultipleActiveResultSets=True" 

providerName="System.Data.SqlClient”

Related Links

About these ads

3 thoughts on “Universal ASP.NET Providers??? Getting SQL Azure to handle your Session State

  1. I Eric what do i need to change to enable Universal Providers Session State Provider in addition to configure the right connection string in web config and adding the Reference to System.Web.Providers?
    Do i need to prepare my SQL Azure Database with a script to create the appropriate tables?

    • I’ve already setup my environment to work with Universal Providers. Unfortunately i’m still facing a problem the Session State only works for me when i publish the web application in windows azure. When i use the SQL Azure connection string locally in Compute Emulator or when i use a Connection String that points out to my SQL Server 2008 R2 installation the Session State is not maintained?! I wonder what might be wrong….

  2. Pingback: management, rdp, Google OAUTH, SSL, web-publish certificates in azure; trying to deploy federated logon! « Peter's ruminations

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s