在我的应用程序中,我需要下载一个文件,所以我正在使用这段代码:
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename =" + strFileName + ".xls");
Response.TransmitFile(strFilePath);
Response.End();
在Response.End()
我得到一个错误ThreadAbortException
为了避免这个错误,我尝试使用 httpApplication.CompleteRequest(),但我也无法使用它。
httpApplication.CompleteRequest() 的代码如下,
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename =" + strFileName + ".xls");
Response.TransmitFile(strFilePath);
HttpApplication.CompleteRequest();
我在使用 HttpApplication.CompleteRequest() 时收到此错误
An object reference is required for the non-static field, method, or property 'System.Web.HttpApplication.CompleteRequest()'
我希望我能够澄清我的疑问......帮助我......