Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Mini Profiler Exception on MiniProfiler.Stop()

I'm just added Mini Profiler to my MVC3 project with nuget and I've followed the basic steps to get it set up. Starting the profile on Application_BeginRequest() and stopping it on Application_EndRequest()

    protected void Application_BeginRequest()
    {
        if (Request.IsLocal)
        {
            MiniProfiler.Start();
        }

    }

    protected void Application_EndRequest()
    {
        MiniProfiler.Stop();
    }

MiniProfiler.Stop() is throwing an exception - "Server cannot append header after HTTP headers have been sent."

Has anybody else seen this?

like image 606
BZink Avatar asked Jul 23 '11 03:07

BZink


2 Answers

Old question but answering anyway.

Problem caused by some component (SignalR in my case) calls HttpResponse.Flush. Solved by excluding SignalR from profiling. Below is a simple version of what we have done.

if (Request.IsLocal && !Request.Path.StartsWith("/signalr"))
{
    MiniProfiler.Start();
}

Hope it helps.

like image 126
Erdogan Kurtur Avatar answered Oct 29 '22 23:10

Erdogan Kurtur


This appears to be related to Combres (http://combres.codeplex.com/). If I ignore the requests for my js and css that has been combined and compressed with combres the profiler seems to work better (no exception being thrown)

like image 1
BZink Avatar answered Oct 30 '22 00:10

BZink