Save generated response stream as a html file

T

Tom Vergote

Hello world,

I'm running into an issue where I would like to save the response stream as
an html file on the server (and convert it to a pdf)

I've tried putting a streamreader on the outputstream like in the following
code, but the stream doesn't seem to be readable

Is there any way to do this?

--- CODE----
string path = Server.MapPath("testfile.html");
StringWriter sw = new StringWriter();


StreamWriter sWriter = File.CreateText(path);
sWriter.WriteLine(sw.ToString());
StreamReader sr = new StreamReader(Response.OutputStream);
sWriter.Write(sr.ReadToEnd());
sWriter.Close();
string pdf = Run(path); // THIS SHOULD CONVERT TO PDF
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/pdf";
try
{
Response.WriteFile( MapPath( pdf ) );
Response.Flush();
Response.Close();
}
catch (Exception ex)
{
Response.ClearContent();
}
-----/CODE-------
 
J

John Saunders

Tom Vergote said:
Hello world,

I'm running into an issue where I would like to save the response stream as
an html file on the server (and convert it to a pdf)

Look into HttpResponse.Filter. It may serve your needs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top