DownloadFile with "save as"

I need to write a process to download an html file locally in my vb.net web application. I am currently using webClient.DownloadFile:

Dim myWebClient As New System.Net.WebClient
myWebClient.DownloadFile("http://archive.ncsa.illinois.edu/primer.html", _
                        "C:\test.html")

Is there a built-in way to do this with the Save As window so that the user can select the location to which they would like to save the file? Or do I need to write my own?

+3
source share
3 answers

you can use

Response.AddHeader("Content-Disposition", "attachment;filename=testfile_file.html");
Response.Write or Response.WriteFile
+5
source

As long as I understand that this is not the answer to your question (see commentary on Thomas's answer), sometimes simple is simple - this is a good way to go

Please right-click this link and save the file
<a href=""http://archive.ncsa.illinois.edu/primer.html">HTML Primer</a>
+1
source

Response.ContentType = "report/rpt";

Response.AppendHeader("Content-Disposition", "attachment; filename=CrystalReport1.rpt");

Response.TransmitFile(Server.MapPath("CrystalReport1.rpt"));

Response.End();
0

All Articles