How to implement a file download in ASP.NET AJAX

前端 未结 4 1360
-上瘾入骨i
-上瘾入骨i 2021-02-04 15:22

I would like to use standard ASP.NET file download response, like in other Stack Overflow question.

Response.ContentType = \"application/octet-stream\";
Respo         


        
4条回答
  •  我在风中等你
    2021-02-04 16:10

    You need to have this in a separate aspx that does not use ajax. Ajax is updating existing html markup on a page at the client side. What you try here is replace the responce content on the server side before sending anything to the client.

    You could try this:

    Have a page called Download.aspx that contains the transmit code you already have.

    In your original page, you have a javascript call that calls the download page like this:

    window.location.replace('Download.aspx');
    

提交回复
热议问题