Dynamic Page to an HTML Page
HOW TO: Archive the Results of a Dynamic Page to an HTML Page in ASP.NET by Using Visual C# .NET
Article ID | : | 810205 |
Last Review | : | May 21, 2003 |
Revision | : | 3.0 |
For a Microsoft Visual Basic .NET version of this article, see 811162 (http://support.microsoft.com/kb/811162/EN-US/).
On This Page
IN THIS TASK
• | SUMMARY
|
||||||||
• | REFERENCES |
SUMMARY
This step-by-step article describes how to retrieve the HTML results of a page as a stream and then download the stream to a file. When you use the FileStream object and set the Response.Filter property to the FileStream object, all HTTP output that Response.Write sends also downloads as stream to a file.
Create a Web Form
To create a Web Form:1. | In Visual C# .NET, create a new ASP.NET Web Application project named ASPNETFilter. |
2. | Right-click the designer pane of WebForm1.aspx. |
3. | Click View HTML Source to edit the HTML code. |
4. | Replace the existing code with the following code :
|
Create the ResponseFilter Class
To create the ResponseFilter class:1. | Add a new class named ResponseFilter.cs. | ||||
2. | Replace the existing code with the following code:
Note Before you run the Web application:
|
Use the Response Filter Class
1. | In Solution Explorer, select WebForm1.aspx. |
2. | Right-click and then select View Code. |
3. | Add the following code to theOnInit event code:
|
Test the ResponseFilter
1. | Save the changes to the ASPNETFilter Web project. |
2. | On the Build menu, select Build Solution. |
3. | Start Microsoft Internet Explorer, and then open WebForm1.aspx by specifying the following URL, where IISServerName is the name of your Microsoft Internet Information Services (IIS) server:
|
4. | Find the Response.htm file in the C:\FilterOutput folder. |