473,789 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Jul 21 '05 #1
4 4884
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********@yah oo.com> wrote in message
news:fb******** *************** *********@4ax.c om...
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.

Jul 21 '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********@yah oo.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.


Jul 21 '05 #3
The Render* methods of the
System.Web.UI.H tmlControls.Htm lControl/System.Web.UI.W ebControls.WebC ontrol
may be called manually to stream the HTML to a TextWriter.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dr. StrangeDub" <st********@yah oo.com> wrote in message
news:fb******** *************** *********@4ax.c om...
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.

Jul 21 '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\myFil e.htm";
StreamWriter sw = new StreamWriter(m_ OutputFile,true );
Server.Execute( "ReportWindow.a spx", sw);
sw.Flush();
sw.Close();

Michael Rose
=============== =
On Wed, 01 Sep 2004 12:57:42 -0500, Dr. StrangeDub
<st********@yah oo.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.


Jul 21 '05 #5

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

Similar topics

7
3236
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 generated, though. I'd like to capture the NAME of every HTML form field element on the server, even if that element is submitted blank. The trouble is, with, say, radio buttons or checkboxes for example, a *blank* element does not get submitted at all.
5
5627
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
4
1285
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 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. ...
4
3219
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 (correct me if I am wrong) it seems that by the ProcessRequest event, the Request has been completely sent and aspnet_wp has used it to hydrate the httpcontext instance. Is there a .net way of capturing an http request as it comes in to the...
4
1977
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 type and the context of the server control itself. Clear as mud? :-) Consider the following server control... <asp:textbox id="MemberEmail" runat="server" ></asp:textbox> TextBox renders at run-time as an HTML control... <input...
4
1424
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 Google Desktop. It is very simple, I wish to send an http request asking for the results in XML. ( by adding &format=xml to the end of the url) i would like to capture the response from the Google Desktop server, (on the local machine) and save...
10
6022
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 code is in C#/ASP.NET. TIA. Andrew.
2
1729
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 dropdownlist control on the page. The error is RegisterForEventValidation can only be called during Render(); Any ideas? Ken Microsoft MVP
1
1002
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 it wit a server.execute, but it raises an exception. It complains about 'infinite loop or infinite recursion' i.e. Dim writer As StringWriter = New StringWriter()
0
9663
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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,...
0
10195
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 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...
1
10136
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,...
0
9979
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 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...
0
9016
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6765
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();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2906
bsmnconsultancy
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...

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.