强制PDF下载时使用Response.End

Pro*_*ing 10 c# asp.net httpresponse

最近我们遇到了一个问题,其中一个开发人员将代码行从使用HttpResponse.End改为使用HttpApplication.CompleteRequest时强制PDF以类似于以下方式下载:https: //stackoverflow.com/a/8590579/3856039

这样做会导致某些PDF由于不间断的空间问题而无法下载,因此代码已更改回使用状态HttpResponse.End.

然而,在帮助我的同事进行一些研究时,我遇到了以下问题: Response.End()被认为是有害的吗?

链接到:https: //blogs.msdn.microsoft.com/aspnetue/2010/05/25/response-end-response-close-and-how-customer-feedback-helps-us-improve-msdn-documentation/

鉴于MSDN博客文章中记录的内容,听起来好像使用HttpResponse.End是错误的方法,所以我想知道它是否甚至需要或是否有更好的方法?

Par*_*esh 0

这是我过去使用过的方法

// Sends all currently buffered output 
HttpContext.Current.Response.Flush(); to the client.

// Gets or sets a value indicating whether to send HTTP content to the client.
HttpContext.Current.Response.SuppressContent = true;

/* Causes ASP.NET to bypass all events and filtering in the HTTP pipeline 
   chain of execution and directly execute the EndRequest event. */
HttpContext.Current.ApplicationInstance.CompleteRequest(); 
Run Code Online (Sandbox Code Playgroud)