MVC Mini Profiler Exception on MiniProfiler.Stop()

一曲冷凌霜 提交于 2019-12-12 10:37:35

问题


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?


回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/6798028/mvc-mini-profiler-exception-on-miniprofiler-stop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!