【问题标题】:Configuring session on windows azure在 Windows azure 上配置会话
【发布时间】:2011-06-17 18:49:15
【问题描述】:

我正在使用本地系统在 Windows azure 上测试会话。我在 web.config 中做了以下配置

<appSettings>
    <!-- account configuration -->
    <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==" />
    <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>
  <system.web>

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

但现在我收到以下错误

配置错误描述:一个 处理过程中发生错误 所需的配置文件 服务这个请求。请查阅 下面的具体错误详细信息和 修改你的配置文件 适当的。

解析器错误消息:异常有 被目标抛出 调用。

来源错误:

第 39 行:第 40 行:
第 41 行: 第 42 行: 行 43:

源文件: C:\Users\GizaKarthik\Desktop\SessionDemo\SessionDemo\SessionDemo_WebRole\web.config 线路:41

装配负载跟踪:以下 信息可能有助于 确定为什么装配 'Microsoft.WindowsAzure.StorageClient, 版本=1.0.0.0,文化=中性, PublicKeyToken=31bf3856ad364e35' 可以 未加载。

警告:程序集绑定日志记录是 关掉。启用程序集绑定 失败记录,设置注册表 价值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) 为 1。 注意:有一些 与相关的性能损失 程序集绑定失败日志记录。转 关闭此功能,删除注册表 价值 [HKLM\Software\Microsoft\Fusion!EnableLog]。

【问题讨论】:

    标签: session azure-storage


    【解决方案1】:

    异常的原因是我使用了损坏的 dll。从 here 下载其他 c# 示例。在TableStorageSessionstateProvider中找到asp提供的项目编辑代码

    找到这个代码

                else            
                {     
                        byte[] items = Convert.FromBase64String(reader.ReadLine());
                        byte[] statics = Convert.FromBase64String(reader.ReadLine());
                        int timeout = session.Timeout;
                        // Deserialize the session
                        result = DeserializeSession(items, statics, timeout);
    
                }
    

    用这个替换上面的代码

                else
                {
                    try // Added try statement   
                    {
                        // Read Items, StaticObjects, and Timeout from the file
                        byte[] items = Convert.FromBase64String(reader.ReadLine());
                        byte[] statics = Convert.FromBase64String(reader.ReadLine());
                        int timeout = session.Timeout;
                        // Deserialize the session
                        result = DeserializeSession(items, statics, timeout);
                    }
                    catch (Exception e) // Added catch statement
                    {
                        // Return an empty SessionStateStoreData   
                        result = new SessionStateStoreData(new SessionStateItemCollection(),
                                                           SessionStateUtility.GetSessionStaticObjects(context),
                                                           session.Timeout);
                    }
    
                }
    

    然后编译并使用 dll。它应该像冠军一样工作。编码愉快!

    【讨论】:

      猜你喜欢
      • 2015-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多