Sometimes when using the miniprofiler, there's just some requests that you doesn't care about. In my case I don't care much about signalr, umbraco pings, and some requests made when I wanna know if the user is idle or not.
To avoid the miniprofiler using energy on (and providing results for) these types of requests, I have added the following code to my global.asax.cs file:
protected void Application_BeginRequest()
{
if (
(Request.IsLocal || Request.UserHostAddress == "37.49.143.197")
&& !(Request.RawUrl.Contains("/signalr/")
|| Request.RawUrl.Contains("/idle/verify")
|| Request.RawUrl.Contains("/idle/interaction")
|| Request.RawUrl.Contains("/umbraco/ping")
)
)
{
MiniProfiler.Start();
}
}
Seeing that I still recieve results for URL's containing the given strings, I have made this check later on in the Application Life Cycle in an attempt on removing the unwanted results I could see that I still got.
protected void Application_ProcessRequest()
{
if (Request.RawUrl.Contains("/signalr/")
|| Request.RawUrl.Contains("/idle/verify")
|| Request.RawUrl.Contains("/idle/interaction")
|| Request.RawUrl.Contains("/umbraco/ping")
)
{
MiniProfiler.Stop(discardResults: true);
}
}
But even though I have done this, I am still recieving the unwanted results. Does anyone know how this can be, what am I doing wrong here?
Notes
It should be noted that because I'm using Umbraco as my fundament, I'm using MiniProfiler 2.1.0 and I start out my Global.asax.cs file like this:
public class MvcApplication : UmbracoApplication
{
protected override void OnApplicationStarted(object sender, EventArgs e)
{
// Setup profiler for Controllers via a Global ActionFilter
GlobalFilters.Filters.Add(new ProfilingActionFilter());
// initialize automatic view profiling
var copy = ViewEngines.Engines.ToList();
ViewEngines.Engines.Clear();
foreach (var item in copy)
{
ViewEngines.Engines.Add(new ProfilingViewEngine(item));
}
...