asp.net web api - MiniProfiler with Web.API 2; is there a global magic request context object? -


I am trying to set up a miniprofile on my Web API site, and MiniProfiler.Current to work.

I followed the guidelines at miniprofiler.com, and the following is global. Ax:

  protected zero application_Start () {MiniProfilerEF6.Initialize (); // Other setup} Safe void Application_BeginRequest () {// UI MiniProfiler.Start () is required to be started here to present; } Secure Zero application_EndRequest () {MiniProfiler.Stop (); }   

This uses the default, which stores the actual code in HttpContext.Current.Items .

When I miniprofiler Current , this HTTCPN.NET Current .

when I request one of my web API URLs:

  • creates the application_BuyRequest profile, Code> HttpContext.Current
  • can store in a Web API MessageHandler in a Web API IActionFilter , HttpContext. Current in HttpContext.Current
  • See now, and try my MiniProfiler.Current.Step ("Administrator: Action") failed Gets
  • different services to my EF queries Running is not recorded because it depends on the MiniPropiler Hook MiniProfiler.Current , which is the HTTP Consort. Current , which is no longer valid
  • Application_EndRequest fire, and httpctx The current is magically back, and so it wrappers the profiler and tells me when this request has started

    I opened the code, and I used my own IProfileProvider I can create, store more reliable programmer objects than HttpContext.Current , but I do not know where it can be.

    I spend a few hours, t find a practical solution:

    • IProfileProvider is a global variable; Either all worker threads in the MVC or Web API pipeline will have to use the same IProfileProvider
    • , I request that the Web API RequestContext to exclude the HTTP Context. Can I move around in properties? , But it does not really help because my IProfileProvider is global in the entire app; If I ask it to store the profile in HttpContext A, then any request for other HTTC Contexts is going to pollute the profile
    • I rely on any kind of threadstodge due to the async I can not wait / reuse the thread dynamically
    • I can not stick the profile object in Ninject binding from InRequestScope because InRequestScope Web API does not work with 2.1, but even if I
    • everyone httpexquest message Properties New HTTPPTC.Internet ITEMS , but still, IProfileProvider is a global variable and I have no way of ensuring that each request is being viewed on their version HttpRequestMessage MiniProfiler.Current can be called from anywhere, so I think the global IProfileProvider will have to inspect the call stack and there HttpRequestMessage Need to find? It seems like madness.

      I am at a loss, what exactly do I want to do.

      I understood the process of putting together the question HttpContext.Current When you are waiting for Async / things:

      I had to configure the web. My filter was adjusted to change when configured, and using Miniprofiler.



Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -