带有TableStorage SessionStateProvider的DataServiceRequestException

带有TableStorage SessionStateProvider的DataServiceRequestException,session,azure,azure-storage,azure-web-roles,asp.net-session,Session,Azure,Azure Storage,Azure Web Roles,Asp.net Session,我正在尝试使用Azure培训工具包中的TableStorage SessionStateProvider。我可以毫无问题地使用该示例,但当我在web应用程序中使用它时,我会遇到以下例外情况: System.Data.Services.Client.DataServiceRequestException occurred Message=An error occurred while processing this request. Source=Microsoft.WindowsAzur

我正在尝试使用Azure培训工具包中的TableStorage SessionStateProvider。我可以毫无问题地使用该示例,但当我在web应用程序中使用它时,我会遇到以下例外情况:

System.Data.Services.Client.DataServiceRequestException occurred
  Message=An error occurred while processing this request.
  Source=Microsoft.WindowsAzure.StorageClient
  StackTrace:
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
       at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
       at Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider.<>c__DisplayClass5.<ResetItemTimeout>b__4()
  InnerException: System.Data.Services.Client.DataServiceClientException
       Message=<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code>UpdateConditionNotSatisfied</code>
  <message xml:lang="en-US">The update condition specified in the request was not satisfied.
RequestId:c552d552-ba1c-4920-84fc-e716705b58b9
Time:2011-02-17T12:43:38.5650557Z</message>
</error>
       Source=System.Data.Services.Client
       StatusCode=412
       StackTrace:
            at System.Data.Services.Client.DataServiceContext.SaveResult.<HandleBatchResponse>d__1e.MoveNext()
       InnerException: 
我已经尝试过了,但到目前为止运气不佳。我还看到发生了空引用异常,因此我猜TableStorage SessionStateProvider的行为与InProc的不同,因此我可能必须检查应用程序中如何使用会话。但是,有什么问题吗

编辑:嗯,我发现如果您仅使用TableStorage SessionStateProvider,Azure培训工具包中的示例也会失败,但有相同的异常。您只需对其他提供商进行评论:



如果您想知道
表存储会话提供程序出现此错误的原因,请参阅我的答案。如果您想了解如何在Azure中使用SQL会话提供程序,请参阅的答案


如果您现在需要使用某些东西,那么您唯一真正的选择就是使用SQL会话提供程序,即使它不受支持。一旦AppFabric缓存退出CTP,这将是一条出路。

我不知道具体如何修复此问题,但我将警告您,此特定会话提供程序不应用于生产解决方案。它本身不会清理(过期的会话值不会被删除),而且它也有点不稳定。如果您需要更可靠的解决方案,您可能希望签入Azure AppFabric缓存服务。它还有一个被证明更可靠的会话提供程序。Azure AppFabric在CTP中,根据AppFabricLabs的使用条款,您不允许在商业应用程序中使用它。我们正在寻找一个临时解决方案,直到2011年第2季度,也就是说AppFabric缓存服务应该发布的时候(如果我没有错的话)。我不敢相信共享会话状态的选项是:这个垃圾和CTP中的东西,因为Microsoft不支持在SQLAzure中保存会话状态。
<authentication mode="Forms">
  <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>

<!-- Membership Provider Configuration -->
<!--<membership defaultProvider="TableStorageMembershipProvider" userIsOnlineTimeWindow="20">
  <providers>
    <clear />
    <add name="TableStorageMembershipProvider" type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageMembershipProvider" description="Membership provider using table storage" applicationName="AzureStore" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" requiresUniqueEmail="true" passwordFormat="Hashed" />
  </providers>
</membership>

<profile>
  <providers>
    <clear />
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
  </providers>
</profile>

--><!-- RoleManager Provider Configuration --><!--
<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="AzureStore" />
  </providers>
</roleManager>-->

<!-- SessionState Provider Configuration -->
<sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
  <providers>
    <clear />
    <add name="TableStorageSessionStateProvider" type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider" applicationName="AzureStore" />
  </providers>
</sessionState>
    <machineKey decryption="AES" decryptionKey="F7FA540B4DFD82E5BB196B95D15FF81F5B973B5514F973D2A46B4C52224A3ABC" validation="SHA1" validationKey="5B973B5514F973D2A46B4C52224A3ABC90378EFA9DE62168764FF0DCE537184F0535D5D9AD66DEDC5B973B5514F973D2A46B4C52224A3ABC90378EFA97DC1ABF" />