943,970 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 2160
  • ASP.NET RSS
Nov 9th, 2009
0

save .aspx page as .html file

Expand Post »
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()
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rikb53 is offline Offline
6 posts
since Nov 2009
Nov 9th, 2009
0
Re: save .aspx page as .html file
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:

ASP.NET Syntax (Toggle Plain Text)
  1. Response.Clear()
  2. Response.Buffer = True
  3. Response.ContentType = "text/html"
  4. Response.ContentEncoding = System.Text.Encoding.UTF8
  5.  
  6. Dim htmlReader As New System.IO.StreamReader("absolute file path of the html file you want to display")
  7. Response.Write(htmlReader.ReadToEnd())
  8. 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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Elbudster is offline Offline
14 posts
since Sep 2004
Nov 9th, 2009
0
Re: save .aspx page as .html file
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rikb53 is offline Offline
6 posts
since Nov 2009
Nov 9th, 2009
0
Re: save .aspx page as .html file
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rikb53 is offline Offline
6 posts
since Nov 2009
Nov 10th, 2009
-7
Re: save .aspx page as .html file
Quote ...
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.
Moderator
Featured Poster
Reputation Points: 1800
Solved Threads: 575
Moderator
jbennet is online now Online
16,520 posts
since Apr 2005
Nov 10th, 2009
0
Re: save .aspx page as .html file
Are you trying to save to an .html file the resulting output of the .aspx page after it is finished rendering? What for?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Elbudster is offline Offline
14 posts
since Sep 2004
Nov 11th, 2009
0

Save .aspx page as .html file

Click to Expand / Collapse  Quote originally posted by rikb53 ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sharmilajv is offline Offline
1 posts
since Nov 2009
Nov 11th, 2009
0
Re: save .aspx page as .html file
Not sure try like
ASP.NET Syntax (Toggle Plain Text)
  1. this.rendercontrol()
Reputation Points: 9
Solved Threads: 13
Junior Poster in Training
chandru7 is offline Offline
72 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Transfer data between pages
Next Thread in ASP.NET Forum Timeline: Redirect a page in a frame target





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC