0

i have looked and looked for this and so far all the code i've downloaded simply doesnt work.
this code (below) works fine - however it opens up the "save file Dialog" and requires that the user select the path to save the .html file.
how can i by-pass that and save the file myself to say - a virtual directory?
any help is greatly appreciated
thanks
rik

Response.Clear()
Response.Buffer = True
Response.ContentType = "application/html"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.AddHeader("Content-Disposition", "attachment;filename=Test.html")
Response.Charset = ""
EnableViewState = False
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
pnMyPanel.RenderControl(oHtmlTextWriter)
Response.Write(oHtmlTextWriter.ToString())
Response.Close()

5
Contributors
7
Replies
9
Views
7 Years
Discussion Span
Last Post by chandru7
0

I'm not 100% sure of what you are trying to do. Do you basically want to output a plain html file from a .aspx page? There are a few ways you could go about doing this. I changed your code around a little bit and this works on a test page that I put together:

Response.Clear()
Response.Buffer = True
Response.ContentType = "text/html"
Response.ContentEncoding = System.Text.Encoding.UTF8

Dim htmlReader As New System.IO.StreamReader("absolute file path of the html file you want to display")
Response.Write(htmlReader.ReadToEnd())
htmlReader.Close()

The file path would be the location of the html file on the server. If you can post more details about what you are trying to accomplish it would help.

Hope this helps.

0

i need to actually Write the .html file contents to a virtual folder. such as Dim vpath As String = Server.MapPath("myFile"). as soon as the user navigates to the .aspx page - they could still see that page. i just need some additional processing to "save" that as a separate .html file, without intervention from the user. hopefully that's a little more clear as to what im trying to do. thanks again. rik

0

i guess the "short" of it would be i want to by-pass the save-file-dialog (so the user is not involved) and save to a pre-determined folder

0

i guess the "short" of it would be i want to by-pass the save-file-dialog (so the user is not involved) and save to a pre-determined folder

most lilely not possible. the web browser is supposed to be sandboxed and allowing a site access to any path on disk without user intervention in that way would represent a security hole.

0

Are you trying to save to an .html file the resulting output of the .aspx page after it is finished rendering? What for?

0

i have looked and looked for this and so far all the code i've downloaded simply doesnt work.
this code (below) works fine - however it opens up the "save file Dialog" and requires that the user select the path to save the .html file.
how can i by-pass that and save the file myself to say - a virtual directory?
any help is greatly appreciated
thanks
rik

Response.Clear()
Response.Buffer = True
Response.ContentType = "application/html"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.AddHeader("Content-Disposition", "attachment;filename=Test.html")
Response.Charset = ""
EnableViewState = False
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
pnMyPanel.RenderControl(oHtmlTextWriter)
Response.Write(oHtmlTextWriter.ToString())
Response.Close()

....................................................................
how to give the .aspx page as the input to this coding

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.