Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

PHP's output buffer and ASP.NET's Response.OutputStream

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kellygreer1 - 12 Dec 2007 18:30 GMT
PHP will alllow you to build up an entire page and before sending that
out as the response.... you can grab all the text and do search and
replaces, add comments, make more CSS/XHTML compliant, etc...

I have bee trying to do the same thing in ASP.NET by manipulating the
Response.OutputStream.
I keep getting the error:
Exception Details: System.ArgumentException: Stream was not readable.
On this line:
StreamReader sr = new StreamReader(Response.OutputStream, true);

What is the correct way to read from this stream? and then push back
in your own contents and then let the Response complete?

Thanks,
Kelly Greer
kellygreer1@nospam.com
replace nospam with yahoo
John Timney (MVP) - 12 Dec 2007 19:02 GMT
You can do that by overriding the render event, completly replacing the HTML
should you choose to do so.....or in an ihttpmodule you can add a
response.filter method

http://microsoft.apress.com/asptodayarchive/73666/enforcing-xhtml-compliance-in-
aspnet-applications


Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

> PHP will alllow you to build up an entire page and before sending that
> out as the response.... you can grab all the text and do search and
[quoted text clipped - 14 lines]
> kellygreer1@nospam.com
> replace nospam with yahoo
kellygreer1 - 12 Dec 2007 22:28 GMT
On Dec 12, 2:02 pm, "John Timney \(MVP\)"
<xyz_j...@timney.eclipse.co.uk> wrote:
> You can do that by overriding the render event, completly replacing the HTML
> should you choose to do so.....or in an ihttpmodule you can add a
[quoted text clipped - 24 lines]
> > kellygre...@nospam.com
> > replace nospam with yahoo

Thanks for the info.  So when you Override the Render method is this
the only place where you can manipulate the Response.OutputStream?  or
do you get the existing "Rendered Text" as a String from somewhere
else?

Thanks,
Kelly
John Timney (MVP) - 12 Dec 2007 22:41 GMT
Each control has a render method, as does page.  Heres an example you can
add to a page to see the results.

protected override void Render(HtmlTextWriter writer) {
 // extract all html and override  <h2>News List</h2>
 System.IO.StringWriter str = new System.IO.StringWriter();
 HtmlTextWriter wrt = new HtmlTextWriter(str);
 // render html
 base.Render(wrt); //CAPTURE THE CURRENT PAGE HTML SOURCE AS STRING
 wrt.Close();
 string html = str.ToString();
 html = html.Replace("text", "<h2>TEXT</h2>");
   // write the new html to the page
 writer.Write(html);
}

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

> On Dec 12, 2:02 pm, "John Timney \(MVP\)"
> <xyz_j...@timney.eclipse.co.uk> wrote:
[quoted text clipped - 35 lines]
> Thanks,
> Kelly

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.