473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6219
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5574
by: Mike - EMAIL IGNORED | last post by:
I have a VC++6.0 program than calls library functions that write to cerr. I would like to capture this output in the calling program. Would you please let me know how I could to this? If I...
2
2883
by: Marcin | last post by:
hello, Anyone has an idea how can I delay the preview from my camera about 4 minutes? I want to delay capturing stream and then show it on screen. I used Stream Buffer Engine but I can't lock...
2
5376
by: John | last post by:
Hi, In Win App, I used Process class to start a new console appliaction, is it possible to capture the console output and display them in a textbox? Thanks very much! John
2
6927
by: Kavvy | last post by:
Hi, Can anyone tell me why the following code produces the error "An object reference is required for the nonstatic field, method, or property 'System.Web.HttpResponse.Redirect(string)'"
7
1181
by: ndessai | last post by:
Hi All, I discovered following issue with the VC 7.1 compiler regarding the backword compatibility. I created a dll (Redirect.dll) which exposes a function and simply writes some text (say...
1
3613
by: Chris Simmons | last post by:
Hello: I am trying to better understand the HttpResponse.Filter property and, although I think I "get it," I am wondering what is going on behind the scenes. I was initially stumped with the...
5
3034
by: Daniel Corbett | last post by:
I am trying to save a file dynamically created in a webpage. I get the following headers, but cannot figure out how to save the attachment. I am basically trying to replicate what internet...
1
2298
by: Jeck621 | last post by:
I like to create a custom code to make custom redirect. For example, I like this URL to be the redirect URL http://testme.now/test to be redirected to http://nowtesting.com. Actuall the /test folder...
4
8132
by: newsgroup.poster | last post by:
I need to set a custom http header before perform http redirection. I do response.AppendHeader("aCustomHeader", "aCustomValue") response.Redirect("anUrl") and my added header doesn't show...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5596
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.