Reputation: 432
I want to save the result of processing an ASP page as html file. Anyone knows if is that possible? Thanks
Upvotes: 1
Views: 1471
Reputation: 4672
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>
Upvotes: 1