Using the Sample Windows Azure ASP.NET Providers

Using the Sample Windows Azure ASP.NET Providers

Rate This
  • Comments 14

Previously, the sample Windows Azure ASP.NET providers were included in the samples folder that was installed with the SDK.

As of the November 2009 release of the Windows Azure Tools & SDK, this is no longer the case.  The samples are available online at http://code.msdn.microsoft.com/windowsazuresamples.

To use these samples:

1. Download the samples and unzip (These are no longer included as part of the samples installed to the SDK folder)

2. Add the AspProviders/Lib/AspProviders.csproj project to the solution by right clicking on the solution and selecting Add | Existing Project… and navigating to the AspProviders.csproj file.

3. Add a reference from your ASP.NET MVC 2 Web role to the AspProviders sample library by right clicking on the “references” folder in the ASP.NET MVC project and selecting “Add Reference…”

image

and selecting the AspProviders assembly:

image

4. Open the web.config file and add/change the providers. 

You can set the applicationName appropriately for your application. 

These sections are added under the system.web element. Note that I'm still tracking down some issues I'm seeing with the profile provider, will update this post when I know more.

Membership Provider:

    <membership defaultProvider="TableStorageMembershipProvider" userIsOnlineTimeWindow = "20">
      <providers>
        <clear/>

        <add name="TableStorageMembershipProvider"
             type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageMembershipProvider"
             description="Membership provider using table storage"
             applicationName="AspProvidersDemo"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             minRequiredPasswordLength="1"
             minRequiredNonalphanumericCharacters="0"
             requiresUniqueEmail="true"
             passwordFormat="Hashed"
                />

      </providers>
    </membership>

Role Manager Provider:

  <roleManager enabled="true" defaultProvider="TableStorageRoleProvider" cacheRolesInCookie="true" cookieName=".ASPXROLES" cookieTimeout="30"
                 cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration = "true"
                 cookieProtection="All" >
      <providers>
        <clear/>
        <add name="TableStorageRoleProvider"
             type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageRoleProvider"
             description="Role provider using table storage"
             applicationName="AspProvidersDemo"
                />
      </providers>
    </roleManager>

Session State Provider:

        <sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
            <providers>
                <clear />
                <add name="TableStorageSessionStateProvider"
                     type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider"
                     applicationName="AspProvidersDemo"
             />
            </providers>
        </sessionState>

Change the existing appSettings element and the folllowing provider configuration:

  <appSettings>
    <add key = "TableStorageEndpoint" value="http://127.0.0.1:10002/devstoreaccount1"/>
    <add key = "BlobStorageEndpoint" value="http://127.0.0.1:10000/devstoreaccount1"/>
    <add key = "AccountName" value="devstoreaccount1"/>
    <add key = "AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="/>

    <!-- provider configuration -->
    <!-- When using the local development table storage service only the default values given
     below will work for the tables (Membership, Roles and Sessions) since these are the names
     of the properties on the DataServiceContext class -->
    <add key = "DefaultMembershipTableName" value="Membership"/>
    <add key = "DefaultRoleTableName" value="Roles"/>
    <add key = "DefaultSessionTableName" value="Sessions"/>
    <add key = "DefaultProviderApplicationName" value="ProviderTest"/>
    <add key = "DefaultProfileContainerName"/>
    <add key = "DefaultSessionContainerName"/>
  </appSettings>

You can now remove the “ApplicationServices” connection string as all of the providers that referenced it are gone.

6. Hit F5 to debug the application and your application is now using the sample ASP.NET providers that run against Windows Azure storage!

What’s next?  You can bet that we’ll put some more work into these providers to make them better and potentially even provide them as a real library. 

Stay tuned.

Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post
  • Hi.

    I've just updated my solution to use the new samples of nov 2009 and it looks like there is a problem with the hashing of password.

    Subsequent hashing of the same password with the same salt seem to yield different hash.

    Therefore it's impossible to login succesfully !

    Setting the passwordFormat to clear solved the issue.

    Is it a known issue ? It seems like really basic functionality so maybe I missed something.

  • Clement - can you provide me a code sample of the issue you are seeing?

  • Hi,

    I've been trying to get this sample to work using development storage. It seems like blobs with session data are not being removed from the container after user logs out (Session.Abandon() is called).

    Debugging shows that IEnumerable<IListBlobItem> object returned by CloudBlobContainer.ListBlobs() times out when trying to enumerate over blobs to be deleted.

    Has anyone experienced similar behavior?

  • Yes, it seems that session data stored in the blobs, are not being removed, and just keeps on growing and growing.

  • Samples link in step 1 is broken.  Proper link is: http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=windowsazuresamples&DownloadId=8221

  • paulenfield -- thank you, I've updated the link.

  • Hello jnak!

    Do you have any information, on what's happening with the AspProvider sample, any updates coming soon or anything?

  • azurebright - it's on the list, no plans I can share at this point.

  • Feels wired to reference "Samples". I would love to see MS opensource these providers, or at least name their namespaces better.. Not to mention the "googleblity", seems that google ignores code.msdn.microsoft.com completely

  • Hi Carl, great feedback.  We're in the process of figuring out how to support ASP.NET providers in a first class manner and your feedback helps us to prioritize the scenario.

  • I am facing the error while implementing the aspprovider session. It gives me error the following line that it can not seriliazie the objects.

    ((SessionStateItemCollection)store.Items).Serialize(writer1);

    I don't understand what is happening behind the scenes.

  • I am getting the following error in the application.

    Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

    Could you please provide the solution.

  • Vijay - off hand it sounds like you are trying to save an object that doesn't support serialization.  Does the problem occur with the standard providers and SQL Express or is this related only to using the Azure providers?

  • Hi,

    it is possible to deploye html5 pahes in windows azure?

    it's possible plz tell me process

    plz help me

Page 1 of 1 (14 items)