none
ASP.NET MVC3应用程序不能获取Appfabric创建的连接字符串 RRS feed

  • 问题

  • 当安装并配置Appfabric for Windows Server后,在IIS管理器的连接字符串里可以看到有ApplicationServerMonitoringConnectionString 和ApplicationServerWorkflowInstanceStoreConnectionString两个连接串,我有一个asp.net mvc3的应用程序,需要使用这两个连接字符串。但在有些机器上,可以取到,在有些机器上又取不出,不知是何缘故,谁能给个思路? 下面是一些具体的信息:

    Asp.net mvc3中取连接字符串的代码:

     public static string SqlPersistedDBConnectionString
            {
                get {
                    if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["ApplicationServerWorkflowInstanceStoreConnectionString"]))
                    {
                        throw new Exception("ApplicationServerWorkflowInstanceStoreConnectionString is not config.");
                    }
                    return ConfigurationManager.ConnectionStrings["ApplicationServerWorkflowInstanceStoreConnectionString"].ToString(); 
                }
            }

    web.config 配置文件内容:

    <?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=152368
      -->

    <configuration>
      
      <connectionStrings>
      </connectionStrings>
      
      <appSettings>
        <add key="webpages:Version" value="1.0.0.0" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
        <!---Custom settings-->
        <add key="PromotionName" value="Workflow" />
        <add key="HealthReportMode" value="All" /> <!---Simple or All-->
      </appSettings>

      <system.web>
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>

        <authentication mode="Windows">
          <!--<forms loginUrl="~/Account/LogOn" timeout="2880" />-->
        </authentication>
        <identity impersonate="false" />
        <anonymousIdentification enabled="false" />
        <membership>
          <providers>
            <clear />
          </providers>
        </membership>

        <profile>
          <providers>
            <clear />
          </providers>
        </profile>

        <roleManager enabled="false">
          <providers>
            <clear />
           
            <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
          </providers>
        </roleManager>

        <pages>
          <namespaces>
            <add namespace="System.Web.Helpers" />
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Web.WebPages" />
          </namespaces>
        </pages>
      </system.web>

      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
          <modules runAllManagedModulesForAllRequests="false">
              <remove name="RoleManager" />
          </modules>
            <security>
                <authorization>
                    <remove users="*" roles="" verbs="" />
                    <add accessType="Allow" users="" roles="Administrators" />
                </authorization>
            </security>
      </system.webServer>

      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>

    我有两台服务器,都有相同的配置,但是一台能访问,另一台不能访问,不能访问的那台,之前都是可以的,但突然就不行了。

    两台机器配置是:Windows server 2008 R2, IIS7.5 均安装有Appfabric for Windows Server

    • 已移动 孟宪会Moderator 2013年1月9日 3:36 (发件人:一般性问题讨论区)
    2013年1月8日 9:26