【问题标题】:ASP.NET Performance Profiling 404/500 errorsASP.NET 性能分析 404/500 错误
【发布时间】:2012-08-20 14:02:54
【问题描述】:

使用带有 Cassini 的 Visual Studio 性能资源管理器,我试图在我的 (Orchard CMS 1.4.0) ASP.NET MVC3 应用程序上启动分析,但我收到此错误:

网站无法正确配置;获取 ASP.NET 进程信息失败。请求http://localhost:30320/OrchardLocal/VSEnterpriseHelper.axd返回错误:远程服务器返回错误:(404) Not Found。

所以我搜索了一个解决方案,发现 this article 不适用,因为我使用的是 Visual Studio 的开发服务器 (Cassini) 而不是 IIS - 不少于 IIS 6。然后我阅读了 this articlethis article ;在所有这些建议中,唯一有所作为的是将location 部分添加到我的web.config,以授予对VSEnterpriseHelper.axd 的访问权限。但正如其中一篇文章所预测的那样,我的 404 错误只是变成了 500:

网站无法正确配置;获取 ASP.NET 进程信息失败。请求http://localhost:30320/OrchardLocal/VSEnterpriseHelper.axd返回错误:远程服务器返回错误:(500)内部服务器错误。

这些不同文章中的尾随评论对我不起作用。有什么建议么?我想我会在这里发布我的(Orchard 1.4.0)web.config,以防有人发现罪魁祸首:

<?xml version="1.0"?>
<!-- 
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
    </sectionGroup>

    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false" />
  </configSections>

  <appSettings>
    <add key="webpages:Enabled" value="false" />
    <add key="log4net.Config" value="Config\log4net.config" />
  </appSettings>

  <!-- Added this, which eliminated the profiling 
  VSEnterpriseHelper.axd 404 error - and led to a 500 
  error instead. -->
  <location path="VSEnterpriseHelper.axd">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <pages pageBaseType="Orchard.Mvc.ViewEngines.Razor.WebViewPage">
      <namespaces>
        <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" />
        <add namespace="System.Linq"/>
        <add namespace="System.Collections.Generic"/>
        <add namespace="Orchard.Mvc.Html"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <!-- 
        Set default transaction timeout to 30 minutes so that interactive debugging 
        is easier (default timeout is less than one minute)
  -->
  <system.transactions>
    <defaultSettings timeout="00:30:00"/>
  </system.transactions>
  <system.web>
    <!--<trust level="Medium" originUrl="" />-->

    <httpRuntime requestValidationMode="2.0" />
    <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.
    -->
    <compilation debug="true" targetFramework="4.0" batch="true" numRecompilesBeforeAppRestart="250" optimizeCompilations="true">
        <buildProviders>
        <add extension=".csproj" type="Orchard.Environment.Extensions.Compilers.CSharpExtensionBuildProviderShim"/>
      </buildProviders>
      <assemblies>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <remove assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        <remove assembly="System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <remove assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <remove assembly="System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <remove assembly="System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <remove assembly="System.WorkflowServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <remove assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <remove assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <remove assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </assemblies>
    </compilation>
    <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
    -->
    <authentication mode="Forms">
      <forms loginUrl="~/Users/Account/AccessDenied" timeout="2880"/>
    </authentication>

    <!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
            to be displayed in place of a error stack trace.
    -->
    <customErrors mode="RemoteOnly" />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
      <namespaces>
        <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.Linq"/>
        <add namespace="System.Collections.Generic"/>
        <add namespace="Orchard.Mvc.Html"/>
      </namespaces>
    </pages>

    <httpHandlers>
      <!-- see below -->
      <clear />
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>

    </httpHandlers>

    <httpModules>
      <add name="WarmupHttpModule" type="Orchard.WarmupStarter.WarmupHttpModule, Orchard.WarmupStarter, Version=1.0.20, Culture=neutral"/>
    </httpModules>
  </system.web>

  <!-- 
        The system.webServer section is required for running ASP.NET AJAX under Internet
        Information Services 7.0.  It is not necessary for previous version of IIS.
  -->
  <system.webServer>

    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WarmupHttpModule" />
      <add name="WarmupHttpModule" type="Orchard.WarmupStarter.WarmupHttpModule, Orchard.WarmupStarter, Version=1.0.20, Culture=neutral"/>
    </modules>
    <handlers accessPolicy="Script">
      <!-- clear all handlers, prevents executing code file extensions, prevents returning any file contents -->
      <clear/>
      <!-- Return 404 for all requests via managed handler. The url routing handler will substitute the mvc request handler when routes match. -->
      <add name="NotFound" path="*" verb="*" type="System.Web.HttpNotFoundHandler" preCondition="integratedMode" requireAccess="Script"/>
    </handlers>
    <!-- Prevent IIS 7.0 from returning a custom 404/500 error page of its own -->
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="App_Data/Dependencies"/>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0" newVersion="3.0.0.0"/>
        <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0"  />
      </dependentAssembly> 
    </assemblyBinding>
  </runtime>
</configuration>

【问题讨论】:

  • 你运气好吗?我在尝试在 ASP.net 4.0 Web 表单应用程序上运行性能分析器时遇到了同样的错误。到目前为止,我已经尝试了以下方法: 1. 结合了我所有的配置。 2. 去掉 web.config 的只读标志。 3. VSEnterpriseHelper.axd 中添加了位置标志。这些都没有帮助。这有什么关系?在创建 VS.net 的所有努力下,为什么该工具不能生成有意义的错误消息?也许这个错误的解决方案是:使用 ANTS profiler
  • 看到了“手动”解决方案(social.msdn.microsoft.com/Forums/nl/vstsprofiler/thread/…)但还没有尝试过。
  • 这绝对是我的配置文件中的内容,但我觉得我已经尝试了所有建议的解决方法。有点难过,但我正试图让我的老板购买 ANTS 分析器的许可证。我在同一站点上安装后不到 5 分钟就得到了演示。正如我对我的老板所说的那样……你想付给我多少薪水来解决这个问题?为什么不直接购买不需要额外配置的工具。

标签: asp.net-mvc-3 visual-studio-2010 performance profiling orchardcms


【解决方案1】:

在我的情况下,我有

    <validation validateIntegratedModeConfiguration="true" />

在我的 web.config 中设置。当我将其更改为

    <validation validateIntegratedModeConfiguration="false" />

事情神奇地开始了。三个小时的下水道......

【讨论】:

    【解决方案2】:

    我遇到了类似的问题,我找到了一个解决方案。我发现我收到 404 错误,因为 VSEnterpriseHelper.axd 是通过 MVC 路由的,并且无论我在 Web.config 中设置什么,它都会发生。所以我想我应该正确地路由它。所以我添加了路由来处理这个文件,我写了处理程序:

    处理程序:

    public class DefaultRouteHandler : IRouteHandler
    {
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            return new DefaultHttpHandler();
        }
    }
    
    internal class DefaultHttpHandler : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            string contentPath = context.Request.PhysicalPath;
    
    #if DEBUG
            if (contentPath == context.Server.MapPath("VSEnterpriseHelper.axd"))
            {
                var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.GetName().Name == "Microsoft.VisualStudio.Enterprise.AspNetHelper");
                if (assembly == null)
                {
                    if (File.Exists(@"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Enterprise.AspNetHelper.dll"))
                    {
                        assembly = Assembly.LoadFrom(@"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Enterprise.AspNetHelper.dll");
                    }
                    if (File.Exists(@"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Enterprise.AspNetHelper.dll"))
                    {
                        assembly = Assembly.LoadFrom(@"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Enterprise.AspNetHelper.dll");
                    }
                }
                var type = assembly.GetType("Microsoft.VisualStudio.Enterprise.Common.AspNetHelperHandler");
                var handler = (IHttpHandler)Activator.CreateInstance(type);
    
                handler.ProcessRequest(context);
                return;
            }
    #endif
            [...]
        }   
    }
    

    路线定义:

    DefaultRouteHandler defaultHandler = new DefaultRouteHandler();
    routes.Add(new Route("{*resource}", new RouteValueDictionary(), new RouteValueDictionary(), defaultHandler));
    

    【讨论】:

      【解决方案3】:

      我修复了同样的 500 错误,这是你需要做的(部分借用 here 并附有我自己的评论):

      • 确保您对 web.config 文件具有写入权限

      • 如果您的网站已锁定根文件夹的安全性(使用 表单或 Windows 身份验证等),请确保添加 [location] 标签以允许完全访问 vsenterprisehelper.axd 文件,如下所示:

        <location path="VSEnterpriseHelper.axd">
            <system.web>
                <authorization>
                    <allow users="?" />
                </authorization>
            </system.web>
        </location> 
        
      • 确保在 IIS 中为您的站点配置 AXD 扩展

      • 如果您的 AppSettings 存储在单独的配置文件中,并且您的 web.config 使用 configSource 属性引用它们,则会出现问题

      【讨论】:

        【解决方案4】:

        我终于(4 小时后)通过将我的默认 .axd route handlerRouteConfig.cs 移动到主 Global.asax.cs 来解决此问题:

        AreaRegistration.RegisterAllAreas();
        // Register .axd route ahead of WebApiConfig
        RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        GlobalConfiguration.Configure(WebApiConfig.Register);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        

        因为我使用的是WebAPI,所以WebApiConfig 路由在RouteConfig.RegisterRoutes 之前注册了对AXD 的调用,默认情况下.axd exception 是。

        【讨论】:

          猜你喜欢
          • 2016-07-29
          • 1970-01-01
          • 2015-05-26
          • 2011-01-23
          • 1970-01-01
          • 1970-01-01
          • 2014-07-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多