相关疑难解决方法(0)

添加标头时在 end_request 中抛出异常

偶尔我会抛出这个异常(在 elmah 中可见)

System.Web.HttpException: 
Server cannot append header after HTTP headers have been sent.

System.Reflection.TargetInvocationException: Exception has been thrown by the target 
of an invocation. ---> System.Web.HttpException: Server cannot append header after 
HTTP headers have been sent.
   at System.Web.HttpHeaderCollection.SetHeader(String name, String value, 
       Boolean replace)
   at System.Web.HttpHeaderCollection.Add(String name, String value)
   at BettingOnYou.MvcApplication.Application_EndRequest() in /Global.asax.cs:line 55
Run Code Online (Sandbox Code Playgroud)

该行对应于:

protected void Application_EndRequest()
{
    // By default, IE renders pages on the intranet (same subnet) in compatibility mode.  
    // IE=edge forces IE to render in …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc global-asax http-headers

5
推荐指数
1
解决办法
4970
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

global-asax ×1

http-headers ×1