MvcMiniProfiler results request giving 404 in Asp.Net MVC app

后端 未结 1 1720
走了就别回头了
走了就别回头了 2020-12-31 10:37

I am trying to use the MvcMiniProfiler in my Asp.Net MVC application. I installed the latest NuGet package and added all the code from the wiki page into Application_

相关标签:
1条回答
  • 2020-12-31 10:59

    The RegisterRoutes() method is now called automatically (and with appropriate write-locks, etc) by the static constructor, which should in turn be called when you first call MiniProfiler.Start(). This should inject the routes into the route-table.

    So unless you are explicitly clearing the route-table at some point after you have first touched the profiler, it should (all things being equal) work.

    I wonder if this is a security thing. For example, which version of IIS are you running with? In some configs (IIS6 in particular) the path needs to be recognised by the server, or you need to enable a wildcard. If this is the case, please let me know - maybe we can implement some kind of fallback route to an ashx or something.


    Update: the problem is that you aren't saving the results at the end of the query; there is both short-term and long-term storage, and both have default implementations provided - all you need to do is something like:

    protected void Application_EndRequest(object sender, EventArgs e)
    {
        MiniProfiler.Stop(discardResults: !IsAnAdmin());
    }
    

    Update update: you may also need to add the following to web.config, in the <system.webServer>, <handlers> section:

    <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*"
        type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified"
        preCondition="integratedMode" />
    
    0 讨论(0)
提交回复
热议问题