In my web app, I have an aspx page which contains an html table and several lines of text. I need users to be able to download this whole page as a separate file.
In the past I have used the a webclient to do this:
Dim myWebClient As New System.Net.WebClient
myWebClient.DownloadFile(strSource, strDest)
Response.AddHeader("Content-Disposition", "attachment;filename=test.doc")
Response.Write("test.doc")
but it appears this is only able to download html pages.
Can this be done?
The reason you can only download HTML is because .aspx is not served over the internet (only the resulting HTML is).
When you are doing the
myWebClient.DownloadFile()the application is simply making a GET request to the URI and saving the resulting HTML. The .aspx never leaves the server – rather it is processed server side resulting in the HTML you are ending up with.