如果写了 Response.End()
试着把它写到最最后,或者调用 HttpContext.Current.ApplicationInstance.CompleteRequest 方法而不是 Response.End 以跳过 Application_EndRequest 事件的代码执行。
如果写了 Response.Redirect()
使用重载 Response.Redirect(String url, bool endResponse),如:Response.Redirect ("bu.aspx", false);
如果写了Server.Transfer()
使用Server.Execute()方法
原理:
Response.End方法结束页执行,并将执行转移到应用程序的事件管道中的Application_EndRequest事件,
而Response.Redirect和Server.Transfer方法都会内部调用Response.End,所以一样会报这个异常。