Allowing user to download from my site through Response.WriteFile()

前端 未结 3 754
情话喂你
情话喂你 2020-12-22 10:08

I am trying to programatically download a file through clicking a link, on my site (it\'s a .doc file sitting on my web server). This is my code:

string File         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-22 10:25

    Rather than having a button click event handler you could have a download.aspx page that you could link to instead.

    This page could then have your code in the page load event. Also add Response.Clear(); before your Response.ContentType = "Application/msword"; line and also add Response.End(); after your Response.WriteFile(fileInfo.FullName); line.

提交回复
热议问题