网上找的解决方案是在项目属性里不要勾选 代码优化 可是我的项目一直都没有勾选过
这种情况一般是使用了response.end,并将代码放在try catch里,解决办法就是将response.end去掉或正如楼主用HttpContext.Current.ApplicationInstance.CompleteRequest 结束
对于 Response.End,调用 HttpContext.Current.ApplicationInstance.CompleteRequest 方法而不是 Response.End 以跳过 Application_EndRequest 事件的代码执行。
对于 Response.Redirect,请使用重载 Response.Redirect(String url, bool endResponse),该重载对 endResponse 参数传递 false 以取消对 Response.End 的内部调用。例如:
Response.Redirect ("nextpage.aspx", false);
你从哪看出来我使用了response.end 和 HttpContext.Current.ApplicationInstance.CompleteRequest 结束 ????