Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Performance Profiling 404/500 errors

Using the Visual Studio Performance Explorer, with Cassini, I'm trying to launch profiling on my (Orchard CMS 1.4.0) ASP.NET MVC3 application, but I get this error:

The web site could not be configured correctly; getting ASP.NET process information failed. Requesting http://localhost:30320/OrchardLocal/VSEnterpriseHelper.axd returned an error: The remote server returned an error: (404) Not Found.

So I searched for a solution and found this article which didn't apply, because I'm using Visual Studio's development server (Cassini) not IIS - no less IIS 6. Then I read this article and this article; of all those suggestions, the only one that made a difference was adding the location section to my web.config, to grant access to VSEnterpriseHelper.axd. But as one of those articles predicted, my 404 error simply became a 500:

The web site could not be configured correctly; getting ASP.NET process information failed. Requesting http://localhost:30320/OrchardLocal/VSEnterpriseHelper.axd returned an error: The remote server returned an error: (500) Internal Server Error.

The trailing commentaries in these various articles aren't working for me. Any suggestions? I figure I will post my (Orchard 1.4.0) web.config here, in case somebody can spot a culprit:

<?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>
like image 418
Brent Arias Avatar asked Aug 20 '12 14:08

Brent Arias


4 Answers

In my case, I had

    <validation validateIntegratedModeConfiguration="true" />

set in my web.config. When I changed it to

    <validation validateIntegratedModeConfiguration="false" />

things magically started working. Three hours down the drain....

like image 194
Nicholas Piasecki Avatar answered Nov 07 '22 03:11

Nicholas Piasecki


I faced similiar problem, and I found one solution. I found out that I get 404 error because VSEnterpriseHelper.axd is routed through MVC, and it's happening whatever I set in Web.config. So I figured out that I should route it properly. So I added route to handle this file, and I wrote handler:

Handler:

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
        [...]
    }   
}

Route definition:

DefaultRouteHandler defaultHandler = new DefaultRouteHandler();
routes.Add(new Route("{*resource}", new RouteValueDictionary(), new RouteValueDictionary(), defaultHandler));
like image 31
Krzysztof Avatar answered Nov 07 '22 03:11

Krzysztof


I fixed the same 500 error, here is what you need to do (partially borrowed from here with my own comment):

  • Make sure you have write permissions on your web.config file

  • If your website has locked down security on the root folder (using either forms or windows authentication etc), make sure you add a [location] tag to allow full access to the vsenterprisehelper.axd file, like this:

    <location path="VSEnterpriseHelper.axd">
        <system.web>
            <authorization>
                <allow users="?" />
            </authorization>
        </system.web>
    </location> 
    
  • Ensure AXD extensions are configured in IIS for your site

  • There are problems if your AppSettings are stored in a separate configuration file, and your web.config refers to them with a configSource attribute

like image 21
sean717 Avatar answered Nov 07 '22 03:11

sean717


I finally (4 hours later) fixed this by moving my default .axd route handler from RouteConfig.cs into the main 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);

Because I was using WebAPI, the WebApiConfig routes were picking up the calls to the AXD as they were being registered before RouteConfig.RegisterRoutes where the .axd exception is by default.

like image 22
Ian Jones Avatar answered Nov 07 '22 03:11

Ian Jones