想要在azure emulator 1.8中的web角色中实现缓存以进行本地和远程部署吗

想要在azure emulator 1.8中的web角色中实现缓存以进行本地和远程部署吗,azure,Azure,希望在azure emulator 1.8中的web角色缓存中实现缓存以用于本地和部署 我尝试了很多代码,但都不起作用 web.config文件设置 我正在使用azure emulator 1.8版本在visual studio 2012上测试此代码 ------------------------------------------------------------------ 测试缓存的编码 公共部分类\u默认值:第页 { 数据缓存工厂myFactory; 数据缓存myCache; 随

希望在azure emulator 1.8中的web角色缓存中实现缓存以用于本地和部署

我尝试了很多代码,但都不起作用

web.config文件设置

我正在使用azure emulator 1.8版本在visual studio 2012上测试此代码



------------------------------------------------------------------
测试缓存的编码
公共部分类\u默认值:第页
{
数据缓存工厂myFactory;
数据缓存myCache;
随机随机发生器=新随机();
受保护的无效页面加载(对象发送方、事件参数e)
{
myFactory=新的DataCacheFactory();
myCache=myFactory.GetDefaultCache();
字符串Test=“Test1”;
myCache.Put(“MyKey”,Test);
}
}

从阅读开始,然后再阅读。文档中有指向示例和大量代码示例的链接。您的配置用于不存在的缓存-cachePort=“22233”用于旧的Azure Fabric共享缓存,无法与localhost一起使用。

请提供有关您正在尝试执行的操作和已尝试的操作的更多详细信息。
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <!-- Append below entry to configSections. Do not overwrite the full section. -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />
  </configSections>
  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WebRole1-20130503143610;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WebRole1-20130503143610.mdf" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
      </namespaces>
      <controls>
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
      </controls>
    </pages>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
    </authentication>
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </roleManager>
    <!--
            If you are deploying to a cloud environment that has multiple web server instances,
            you should change session state mode from "InProc" to "Custom". In addition,
            change the connection string named "DefaultConnection" to connect to an instance
            of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
      -->
  <sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider" timeout="30">
    <providers>
        <add name="AppFabricCacheSessionStoreProvider" 
             type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider, Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
             cacheName="default"/>
    </providers>
</sessionState>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.ApplicationServer.Caching.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
  <dataCacheClients>
    <dataCacheClient name="default">
      <hosts>
        <host name="localhost" cachePort="22233" />
      </hosts>

      <!--<securityProperties mode="Message">
        <messageSecurity authorizationInfo="e58a8dbc-5093-4124-b5fd-9b9538d72213"></messageSecurity>
      </securityProperties>-->
    </dataCacheClient>

  </dataCacheClients>
</configuration>
------------------------------------------------------------------

Coding for test cache

public partial class _Default : Page
    {
          DataCacheFactory myFactory;
          DataCache myCache;
          Random randomizer = new Random();


        protected void Page_Load(object sender, EventArgs e)
        {


                     myFactory = new DataCacheFactory();
                    myCache = myFactory.GetDefaultCache();
                    string Test = "Test1";
                    myCache.Put("MyKey", Test);
        }
    }