unhandled exception in TableStorageSessionStateProvider

Answered unhandled exception in TableStorageSessionStateProvider

  • Friday, September 23, 2011 10:22 AM
     
      Has Code

    Hi,

    We've experienced problems with our webapplication in Azure. The main problem is that the Session State is somehow lost. This happens only sometimes, not always. Who can help me?

     

    In order to run the webapplication in Azure, I've made a reference to AspProviders.dll (from the azure sdk C:\WAPTK\Labs\WindowsAzureDeploymentVS2010\Source\Assets\AspProviders\bin\Debug\AspProviders.dll), created a Connection String to the Azure Table Storage (the session state is saved in the Table Storage) and added the web.config:

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

     

    Apparently, there is something wrong, because sometimes an error occurs:

    Below you can find a stack trace:

    User agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.2; MS-RTC LM 8)
    Client name: static.kpn.net
    Date: 23-9-2011 8:05:01
    Session status: exists = False
    
    An unhandled exception has occurred:
    Message: Value cannot be null.
    Parameter name: InString
    
    Stack trace:
       at System.Convert.FromBase64String(String s)
       at Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.GetSession(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions, Boolean exclusive) in C:\WAPTK\Labs\WindowsAzureDeploymentVS2010\Source\Assets\AspProviders\TableStorageSessionStateProvider.cs:line 770
       at Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actions) in C:\WAPTK\Labs\WindowsAzureDeploymentVS2010\Source\Assets\AspProviders\TableStorageSessionStateProvider.cs:line 378
       at System.Web.SessionState.SessionStateModule.GetSessionStateItem()
       at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
       at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    
    

     

    Suggestions are very much appreciated!

    Best regards, Leonard

All Replies

  • Friday, September 23, 2011 1:46 PM
     
     

    Hi Leonard,

    Have you taken a look at the System.Web.Providers NuGet package? It doesn't include the TableStorageSessionStateProvider and maybe that's for a reason ;-). 

    This package does include a SessionState provider that enables you to store you're session state in SQL Azure.

     

     


    With regards,

    Patriek

    www.patriekvandorp.net
    If this reply is of help to you, please don't forget to mark it as an answer.
  • Friday, September 23, 2011 2:28 PM
     
     

    Hi Patriek,

     

    No, I haven't look to the NuGet package yet. So what is the reason? Should I avoid the TableStorageSessionStateProvider?

     

    Regards, Leonard

  • Monday, September 26, 2011 7:49 AM
     
     Answered

    Hi Leonard,

    I believe the AspProviders.dll Assembly is a remainder of a Samples solution. All I know is that we experienced a lot of problems with it in production and we decided to use SQL Azure a datastore for session state.

    The System.Web.Providers assembly was released a couple of weeks ago (or is it months already?? ;-)) and is newer than the AspProviders.dll. As it turns out, there's no TableStorageSessionStateProvider in System.Web.Providers anymore, so I figure that storing session state in SQL Azure is the recommended way to go.

    Maybe, with the latest updates of Windows Azure Storage (enabling Upsert for instance), the TableStorageSessionStateProvider will find it's way into the System.Web.Providers assembly in the future, but this is plain speculation.

     


    With regards,

    Patriek

    www.patriekvandorp.net
    If this reply is of help to you, please don't forget to mark it as an answer.
  • Tuesday, September 27, 2011 3:17 PM
     
     

    Hi Patriek,

     

    Thanks for reply. We also experience a lot of trouble with the AspProviders.dll Assembly.

     

    As I understand correctly, you 'solved' this issue by avoiding the AspProvders.dll and to store the session state in SQL Azure. I will try to do the same, thanks for your help.

     

    Regards, Leonard