When downloading a file from ASP .Net, the text file gets appended with HTML content

前端 未结 3 1301
别那么骄傲
别那么骄傲 2021-01-06 02:07

I have made a page that allows users to upload files to the server using a FileUpload Control and handling its event with this code

Sub SaveAttachment()
             


        
3条回答
  •  天涯浪人
    2021-01-06 02:35

    Is is not safe to use Response.End(), It will always return a System.Threading.ThreadAbortException:.. if debugged and seen in the catch block...

    Alternative.. Use the following instead...

    Response.Flush();
    Response.SuppressContent = true;
    Response.WriteFile(filepath);
    HttpContext.Current.ApplicationInstance.CompleteRequest();
    

提交回复
热议问题