Asp.net MVC MiniProfiler "Request is not available in this context" -
I am trying to use MiniProfiler for my MVC application which is using Oracle DB. This is my global.
Protected Zero application_Start () {Area registration. Registrar All Ares (); WebApiConfig.Register (GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters (GlobalFilters.Filters); RouteConfig.RegisterRoutes (RouteTable.Routes); BundleConfig.RegisterBundles (BundleTable.Bundles); MiniProfiler.Start (); // or any other check of the check, etc.} Safe void Application_PreRequestHandlerExecute (Object Sender, EventArgs e) {DevExpressHelper.Theme = "Metropolis"; MiniProfiler.Stop (); // Stop as soon as possible, even with MvcMiniProfiler.MiniProfiler.Stop (discardResults: true); }
When I'm starting the application:
"Request is not available in this context"
You are getting this error because you are running MiniProfiler.Start ()
in the wrong place. You need to run Application_BeginRequest
as part of MiniProfiler.Start ()
. Move it to this function and it should work.
When you run it as part of Application_Start
, then it fails, because it is HttpContext.Current
, which is the Access_Start is not accessible in
.
In the context of the miniprofile, Application_Start
is a good place to create a global MiniProfiler
customization that you want to make for all requests.
Comments
Post a Comment