469,621 Members | 1,685 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

HTTPResponse capture or redirect stream

I have developed an ASP.NET web page with a VB.net for the code behind.
I would like to redirect the output of the web page so I can send it as
an Email. Or Redirect the HTTPResponse stream on the server to a
file. Any ideas would be appreciated.

Thank you
Paul

Nov 19 '05 #1
4 6078
Hi Paul

The following will e.g. write a word file to the browser. In addition
it prompts for a 'Save As...' dialog, even if the browser is normally
set to open this kind of file.

HTH

Martin

'Set Headers
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/x-msdownload"
Response.AppendHeader("Content-Disposition",
"attachment;filename=Test.doc")
'Create Stream
Dim FileStream As System.IO.FileStream = New
System.IO.FileStream("C:\Inetpub\wwwroot\WebApplic ation3\pro*gclient\1\assets\files\documents\key\22 12005210406_1_1.doc",

System.IO.FileMode.Open)
Dim FileSize As Long = FileStream.Length
Dim bBuffer(FileSize) As Byte
FileStream.Read(bBuffer, 0, Convert.ToInt32(FileSize))
FileStream.Close()
'Output To Client
Response.BinaryWrite(bBuffer)
Response.End()

Nov 19 '05 #2
Hi Paul

The following will e.g. write a word file to the browser. In addition
it prompts for a 'Save As...' dialog, even if the browser is normally
set to open this kind of file.

HTH

Martin

'Set Headers
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/x-msdownload"
Response.AppendHeader("Content-Disposition",
"attachment;filename=Test.doc")
'Create Stream
Dim FileStream As System.IO.FileStream = New
System.IO.FileStream("C:\Inetpub\wwwroot\WebApplic ation3\pro*gclient\1\assets\files\documents\key\22 12005210406_1_1.doc",

System.IO.FileMode.Open)
Dim FileSize As Long = FileStream.Length
Dim bBuffer(FileSize) As Byte
FileStream.Read(bBuffer, 0, Convert.ToInt32(FileSize))
FileStream.Close()
'Output To Client
Response.BinaryWrite(bBuffer)
Response.End()

Nov 19 '05 #3
I was not clear. I do not need to display a document. I need to capture
the HTTP response to a file or redirect (not response.redirect) it to
multiple email address. All this must occure on the server.

Paul

Nov 19 '05 #4
Hello Paul,

If you want to save the output to a file, look at the Filter property of
the HttpResponse object.

If you want to email the output, look at RenderControl method of the Page
class.

string output = "";
using (StringWriter sw = new StringWriter())
using (HtmlTextWriter writer = new Html32TextWriter(sw))
{
myPageInstace.RenderControl(writer);
output = sw.GetStringBuilder().ToString();
}

// at this point, output has the html of the rendered page

--
Matt Berther
http://www.mattberther.com
I have developed an ASP.NET web page with a VB.net for the code
behind. I would like to redirect the output of the web page so I can
send it as an Email. Or Redirect the HTTPResponse stream on the
server to a file. Any ideas would be appreciated.

Thank you
Paul


Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Mike - EMAIL IGNORED | last post: by
2 posts views Thread by Marcin | last post: by
2 posts views Thread by John | last post: by
2 posts views Thread by Kavvy | last post: by
5 posts views Thread by Daniel Corbett | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.