473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Capturing ASP.Net generated HTML to a file on web server

I am looking for a way to capture the HTML file generated by an
ASP.Net application (just as is sent back to the client) and save it
to a designated spot on the web server. Here's a bit of background:
our application has a Report function that dynamically creates a new
page containing various tables of real-time data (through the C# code
"behind" the .aspx file). We have a new requirement to add a file
save function to this report page. So, I'd like to capture the final
HTML within the the.aspx file (exactly as is sent to the browser) and
save it (with an .htm extension) on the web server. Think of it as
having the ability to do a "view source" of the final HTML, and then
saving the source back to a file on the web server. Does anyone know
of supported way to capture the generated HTML and save it
server-side? All suggestions welcome and much appreciated.

Michael Rose
Unisys Corp.
Nov 16 '05 #1
4 1262
Hi,

All you have to do is using a WebRequest instance to request that very same
page and later save the stream.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dr. StrangeDub" <st********@yahoo.com> wrote in message
news:fb********************************@4ax.com...
I am looking for a way to capture the HTML file generated by an
ASP.Net application (just as is sent back to the client) and save it
to a designated spot on the web server. Here's a bit of background:
our application has a Report function that dynamically creates a new
page containing various tables of real-time data (through the C# code
"behind" the .aspx file). We have a new requirement to add a file
save function to this report page. So, I'd like to capture the final
HTML within the the.aspx file (exactly as is sent to the browser) and
save it (with an .htm extension) on the web server. Think of it as
having the ability to do a "view source" of the final HTML, and then
saving the source back to a file on the web server. Does anyone know
of supported way to capture the generated HTML and save it
server-side? All suggestions welcome and much appreciated.

Michael Rose
Unisys Corp.

Nov 16 '05 #2
Hi Michael:

I'm not sure if you want to save the HTML from inside the ASP.NET
process or request the HTML from the web server inside a windows form.

Inside ASP.NET you can Server.Execute a page to get the HTML. From a
WinForm app you can use WebClient or WebRequest.

I have some code here:
http://odetocode.com/Articles/162.aspx

HTH,

--
Scott
http://www.OdeToCode.com

On Wed, 01 Sep 2004 12:57:42 -0500, Dr. StrangeDub
<st********@yahoo.com> wrote:
I am looking for a way to capture the HTML file generated by an
ASP.Net application (just as is sent back to the client) and save it
to a designated spot on the web server. Here's a bit of background:
our application has a Report function that dynamically creates a new
page containing various tables of real-time data (through the C# code
"behind" the .aspx file). We have a new requirement to add a file
save function to this report page. So, I'd like to capture the final
HTML within the the.aspx file (exactly as is sent to the browser) and
save it (with an .htm extension) on the web server. Think of it as
having the ability to do a "view source" of the final HTML, and then
saving the source back to a file on the web server. Does anyone know
of supported way to capture the generated HTML and save it
server-side? All suggestions welcome and much appreciated.

Michael Rose
Unisys Corp.


Nov 16 '05 #3
The Render* methods of the
System.Web.UI.HtmlControls.HtmlControl/System.Web.UI.WebControls.WebControl
may be called manually to stream the HTML to a TextWriter.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dr. StrangeDub" <st********@yahoo.com> wrote in message
news:fb********************************@4ax.com...
I am looking for a way to capture the HTML file generated by an
ASP.Net application (just as is sent back to the client) and save it
to a designated spot on the web server. Here's a bit of background:
our application has a Report function that dynamically creates a new
page containing various tables of real-time data (through the C# code
"behind" the .aspx file). We have a new requirement to add a file
save function to this report page. So, I'd like to capture the final
HTML within the the.aspx file (exactly as is sent to the browser) and
save it (with an .htm extension) on the web server. Think of it as
having the ability to do a "view source" of the final HTML, and then
saving the source back to a file on the web server. Does anyone know
of supported way to capture the generated HTML and save it
server-side? All suggestions welcome and much appreciated.

Michael Rose
Unisys Corp.

Nov 16 '05 #4
Thanks to Scott, Ignacio, and Dennis for their replies. I pretty much
went with Scott's suggested use of Server.Execute. This turned out to
be quite easy. I haven't tweaked the code yet, but these five lines of
code esssentially did the job:

m_OutputFile = "c:\myDir\myFile.htm";
StreamWriter sw = new StreamWriter(m_OutputFile,true);
Server.Execute("ReportWindow.aspx", sw);
sw.Flush();
sw.Close();

Michael Rose
================
On Wed, 01 Sep 2004 12:57:42 -0500, Dr. StrangeDub
<st********@yahoo.com> wrote:
I am looking for a way to capture the HTML file generated by an
ASP.Net application (just as is sent back to the client) and save it
to a designated spot on the web server. Here's a bit of background:
our application has a Report function that dynamically creates a new
page containing various tables of real-time data (through the C# code
"behind" the .aspx file). We have a new requirement to add a file
save function to this report page. So, I'd like to capture the final
HTML within the the.aspx file (exactly as is sent to the browser) and
save it (with an .htm extension) on the web server. Think of it as
having the ability to do a "view source" of the final HTML, and then
saving the source back to a file on the web server. Does anyone know
of supported way to capture the generated HTML and save it
server-side? All suggestions welcome and much appreciated.

Michael Rose
Unisys Corp.


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: JDS | last post by:
Hi, all. I'd like to do the following, preferably *without* resorting to JavaScript: I have a long, dynamically-generated form questionnaire. Not all of the form fields are dynamically...
5
by: Earl Eiland | last post by:
Anyone know how to capture text from GUI output? I need to process information returned via a GUI window. Earl
12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
4
by: Dr. StrangeDub | last post by:
I am looking for a way to capture the HTML file generated by an ASP.Net application (just as is sent back to the client) and save it to a designated spot on the web server. Here's a bit of...
4
by: PJ | last post by:
I would like to capture a request stream before the request has been completely sent to the server for the sake of saving the bytes of a posted file to disk. I have written httpmodules before, but...
4
by: clintonG | last post by:
Technically speaking, this issue is not about modifying the HTML generated by server controls but preceding the HTML generated by server controls with an HTML control generated on the basis of the...
4
by: Steve Wolfie | last post by:
Hello all: Again, let me thank everyone who has helped in the past. Can't wait till I can help out with some advice of my own. Now, I am building an app that wishes to retrieve the output of...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
2
by: Ken Cox - Microsoft MVP | last post by:
I'm trying to find a way to program in ASP.NET 2.0 but capture the HTML output. I found the following routine in ASP.NET 2.0 Cookbook from O'Reilly. It doesn't work if I include a server-side...
1
by: Carlos | last post by:
Hi all, I need to capture all the html that is generated after the user fills all the controls on a page. This needs to be captured at the moment the user hits the submit button. I tried doing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
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...

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.