在我的应用程序中,我需要下载一个文件,所以我使用这段代码:
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename =" + strFileName + ".xls");
Response.TransmitFile(strFilePath);
Response.End();
Run Code Online (Sandbox Code Playgroud)
在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();
Run Code Online (Sandbox Code Playgroud)
我在使用HttpApplication.CompleteRequest()时遇到此错误
An object reference is required for the non-static field, method, or property 'System.Web.HttpApplication.CompleteRequest()'
Run Code Online (Sandbox Code Playgroud)
我希望我能够清楚地表达我的怀疑......帮助我......
asp.net ×1