8

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?

BZink
  • 7,687
  • 10
  • 37
  • 55

2 Answers2

7

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.

Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
Erdogan Kurtur
  • 3,630
  • 21
  • 39
1

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)

BZink
  • 7,687
  • 10
  • 37
  • 55
  • Can I just say that Combres (though a well built tool) is probably not something that you want to use. If you're looking to combine and minify your css/js, you should do it at build time in order to lessen server load. [Here's another post I wrote on the subject.](http://stackoverflow.com/questions/6687475/is-there-a-plugin-which-will-automatically-minify-and-cache-javascript/6687530#6687530) – Chase Florell Jul 23 '11 at 16:18
  • Note: the main point in that topic is that you should use [Chirpy](http://chirpy.codeplex.com/) for combining and minifying your JS/CSS - It's a FANTASTIC tool... and no, I don't have any affiliation with them. – Chase Florell Jul 23 '11 at 16:19
  • Thanks for the suggestion. I'll look at Chirpy. Combres was the best thing I could find at the time I was looking, it does seem rather "heavy" though at run time. – BZink Jul 23 '11 at 16:40
  • Chirpy does the work while your designing, so you can put a static file up to the server that is already combined and minified. The config options are really sweet, and I absolutely love the fact that it has .LESS support. – Chase Florell Jul 23 '11 at 18:19