save .aspx page as .html file

Reply

Join Date: Nov 2009
Posts: 4
Reputation: rikb53 is an unknown quantity at this point 
Solved Threads: 0
rikb53 rikb53 is offline Offline
Newbie Poster

save .aspx page as .html file

 
0
  #1
Nov 9th, 2009
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()
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 13
Reputation: Elbudster is an unknown quantity at this point 
Solved Threads: 1
Elbudster Elbudster is offline Offline
Newbie Poster
 
0
  #2
Nov 9th, 2009
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:

  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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 4
Reputation: rikb53 is an unknown quantity at this point 
Solved Threads: 0
rikb53 rikb53 is offline Offline
Newbie Poster
 
0
  #3
Nov 9th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 4
Reputation: rikb53 is an unknown quantity at this point 
Solved Threads: 0
rikb53 rikb53 is offline Offline
Newbie Poster
 
0
  #4
Nov 9th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,273
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 544
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator
 
-7
  #5
Nov 10th, 2009
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.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 13
Reputation: Elbudster is an unknown quantity at this point 
Solved Threads: 1
Elbudster Elbudster is offline Offline
Newbie Poster
 
0
  #6
Nov 10th, 2009
Are you trying to save to an .html file the resulting output of the .aspx page after it is finished rendering? What for?
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 1
Reputation: sharmilajv is an unknown quantity at this point 
Solved Threads: 0
sharmilajv sharmilajv is offline Offline
Newbie Poster

Save .aspx page as .html file

 
0
  #7
Nov 11th, 2009
Originally Posted by rikb53 View 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()
....................................................................
how to give the .aspx page as the input to this coding
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 58
Reputation: chandru7 is an unknown quantity at this point 
Solved Threads: 13
chandru7 chandru7 is offline Offline
Junior Poster in Training
 
0
  #8
Nov 11th, 2009
Not sure try like
  1. this.rendercontrol()
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 625 | Replies: 7
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC