1

I want to save the result of processing an ASP page as html file. Anyone knows if is that possible? Thanks

4
  • All ASP pages are finally rendered as HTML. So you can do it very well! Nov 19, 2012 at 10:27
  • ok thnaks, but I want to save it on the server, can you help me?
    – Mikelon85
    Nov 19, 2012 at 10:30
  • 1
    In asp.net we can use WebRequest object and get response and save it. As i have not worked on ASP i have no idea. But it should be possible, all we need to do is make a request in server side code and process the Response, which is HTML Nov 19, 2012 at 10:33
  • You can use XMLHTTP to scrape your pages and then FSO to save them instead with the .htm extension. If you are trying to save the sites for performance, IIS takes care of caching for you, and its not really necessary. If you want to move them to a server that does not support asp, then you can use a program like HTTPTRACK to copy your whole website, (changes extensions to html)
    – Frank
    Nov 27, 2012 at 9:31

1 Answer 1

1

This can help you save the output of the ASP Page

<script runat="server">
void Page_Load() {
  String inputFile = MapPath("input-page.aspx");
  String sDiskFile = "result.htm";

  WebRequest webRequest = WebRequest.Create(inputFile);

  WebResponse webResponse = webRequest.GetResponse();
  Stream stream = webResponse.GetResponseStream();

  StreamReader oReader = new StreamReader(stream, Encoding.ASCII);

  StreamWriter oWriter = new StreamWriter(Server.MapPath(sDiskFile));
  oWriter.Write(oReader.ReadToEnd());

  oWriter.Close();
  oReader.Close();
  webResponse.Close();

  // display confirmation that it worked
  lblOutput.Text = inputFile;
  aLink.Text = sDiskFile;
  aLink.NavigateUrl = sDiskFile;

}
//-----------------------------------------
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.