【问题标题】:MVC 4 Azure web role: Error 500 when adding the "tracing" element to web.configMVC 4 Azure Web 角色:将“跟踪”元素添加到 web.config 时出现错误 500
【发布时间】:2012-11-06 22:44:07
【问题描述】:

我正在尝试按照此处找到的示例向 Azure Web 角色添加诊断: https://www.windowsazure.com/en-us/develop/net/common-tasks/diagnostics/

当我在system.webserver 下添加tracing 元素时,我在运行网站时看到一个错误。甚至在OnStart 中的断点被命中之前就可以看到该错误。

有什么想法吗?

这是我的web.config 文件,其中有问题的部分已被注释掉:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>    
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </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">
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet_d368ef657c124d629b2577cb9775791c;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <customErrors mode="Off"></customErrors>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <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.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <machineKey decryption="AES" decryptionKey="F7FA540B4DFD82E5BB196B95D15FF81F740A8B17F626BAF1D0889905ACBF0B60" validation="SHA1" validationKey="740A8B17F626BAF1D0889905ACBF0B609712CDA49DE62168764FF0DCE537184F0535D5D9AD66DEDC740A8B17F626BAF1D0889905ACBF0B609712CDA497DC1ABF" />
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <!--<tracing>
      <traceFailedRequests>
        <add path="*">
          <traceAreas>
            <add provider="ASP" verbosity="Verbose" />
            <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
            <add provider="ISAPI Extension" verbosity="Verbose" />
            <add provider="WWW Server"
            areas="Authentication,
                Security,
                Filter,
                StaticFile,
                CGI,
                Compression,
                Cache,
                RequestNotifications,
                Module"
            verbosity="Verbose" />
          </traceAreas>
          <failureDefinitions statusCodes="400-599" />
        </add>
      </traceFailedRequests>
    </tracing>-->
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

【问题讨论】:

    标签: azure web-config asp.net-mvc-4 azure-web-roles


    【解决方案1】:

    这是我解决问题的方法:

    服务器突然开始打印有关 500 错误的详细信息(我不知道为什么,我认为我没有更改任何内容),然后我发现实际错误是:

    HTTP 错误 500.19:

    无法使用唯一键添加类型为“add”的重复集合条目 属性“路径”设置为“*”

    解决方案是在add 标记之前添加以下行:

    &lt;remove path="*"/&gt;

    所以现在tracing 标签看起来像这样:

    <tracing>
          <traceFailedRequests>
            <remove path="*"/>
            <add path="*">
              <traceAreas>
                <add provider="ASP" verbosity="Verbose" />
                <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
                <add provider="ISAPI Extension" verbosity="Verbose" />
                <add provider="WWW Server"
                areas="Authentication,
                    Security,
                    Filter,
                    StaticFile,
                    CGI,
                    Compression,
                    Cache,
                    RequestNotifications,
                    Module"
                verbosity="Verbose" />
              </traceAreas>
              <failureDefinitions statusCodes="400-599" />
            </add>
          </traceFailedRequests>
        </tracing>
    

    这似乎工作正常。

    【讨论】:

      【解决方案2】:

      我注意到您引用了 Microsoft.WindowsAzure.Diagnostics Version=1.8.0.0,它是 10 月 Azure SDK 的一部分,以获取 Azure 侦听器。您的项目中是否包含 Storage 客户端库 1.7? Azure 诊断库 1.8 依赖于较旧的存储客户端库 1.7(不是随 sdk 发布的 2.0)

      【讨论】:

      • 谢谢! StorageClient 库的版本是 1.7.0.0,它可以工作。我应该将 DiagnosticMonitorTraceListener 降级到 1.7.0.0 吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多