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 4 6234
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.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/x-msdownload"
Response.Append Header("Content-Disposition",
"attachment;fil ename=Test.doc" )
'Create Stream
Dim FileStream As System.IO.FileS tream = New
System.IO.FileS tream("C:\Inetp ub\wwwroot\WebA pplication3\pro *gclient\1\asse ts\files\docume nts\key\2212005 210406_1_1.doc" ,
System.IO.FileM ode.Open)
Dim FileSize As Long = FileStream.Leng th
Dim bBuffer(FileSiz e) As Byte
FileStream.Read (bBuffer, 0, Convert.ToInt32 (FileSize))
FileStream.Clos e()
'Output To Client
Response.Binary Write(bBuffer)
Response.End()
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.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/x-msdownload"
Response.Append Header("Content-Disposition",
"attachment;fil ename=Test.doc" )
'Create Stream
Dim FileStream As System.IO.FileS tream = New
System.IO.FileS tream("C:\Inetp ub\wwwroot\WebA pplication3\pro *gclient\1\asse ts\files\docume nts\key\2212005 210406_1_1.doc" ,
System.IO.FileM ode.Open)
Dim FileSize As Long = FileStream.Leng th
Dim bBuffer(FileSiz e) As Byte
FileStream.Read (bBuffer, 0, Convert.ToInt32 (FileSize))
FileStream.Clos e()
'Output To Client
Response.Binary Write(bBuffer)
Response.End()
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.redire ct) it to
multiple email address. All this must occure on the server.
Paul
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 Html32TextWrite r(sw))
{
myPageInstace.R enderControl(wr iter);
output = sw.GetStringBui lder().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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 should ask on another group,
please let me know.
Thanks in advance,
Mike.
|
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 the profile (LockProfile
function gives me an application error.
Help me please.
|
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
|
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)'"
|
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 "Hello World") to stderr stream. I also created a
driver program (driver.exe) and used the exposed function from the above
dll. The driver.exe tries to redirect the stderr stream to a file
"stderr.txt" before calling the method from the dll. (used...
| |
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 thing because all the samples I came
across kept using the property as an argument to the custom filter
Stream's constructor. What I then figured out was that this is the
way that multiple filters can be chained onto the Response stream. For
|
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 explorer would do in this case.
The headers I am getting are:
Headers {Content-Disposition: attachment; filename="dynamic_file.mdb"
Connection: close
Cache-Control: private
Content-Type: application/octet-stream
|
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 should not exists in the IIS because I want a custom redirect right. I write a custom HttpModule to capture the HttpRequest but during debug it doesn't go HttpModule code rather a Page not found was thrown by IIS. I want to capture the request first...
|
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 up, it seems to be erased, if I
remove the redirect, it does.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |