473,403 Members | 2,183 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,403 software developers and data experts.

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

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
ke*********@nospam.com
replace nospam with yahoo
Dec 12 '07 #1
3 2879
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/asptoday...t-applications

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"kellygreer1" <ke*********@yahoo.comwrote in message
news:1a**********************************@p69g2000 hsa.googlegroups.com...
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
ke*********@nospam.com
replace nospam with yahoo

Dec 12 '07 #2
On Dec 12, 2:02 pm, "John Timney \(MVP\)"
<xyz_j...@timney.eclipse.co.ukwrote:
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/asptoday...cing-xhtml-com...

Regards

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

"kellygreer1" <kellygre...@yahoo.comwrote in message

news:1a**********************************@p69g2000 hsa.googlegroups.com...
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
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
Dec 12 '07 #3
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

"kellygreer1" <ke*********@yahoo.comwrote in message
news:38**********************************@l1g2000h sa.googlegroups.com...
On Dec 12, 2:02 pm, "John Timney \(MVP\)"
<xyz_j...@timney.eclipse.co.ukwrote:
>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/asptoday...cing-xhtml-com...

Regards

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

"kellygreer1" <kellygre...@yahoo.comwrote in message

news:1a**********************************@p69g200 0hsa.googlegroups.com...
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
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

Dec 12 '07 #4

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

Similar topics

9
by: James Macbell | last post by:
I think I have pushed ASP.NET to the limit, I am not sure if I have done anything wrong in the code because I am trying to make 2 pieces of code (C# vs PHP) using the same algorithm. Anyways, here...
4
by: pei_world | last post by:
in asp or php, we can use inner output command to print out text or other thing inside out web page. I want to know how to do this in asp.net. I know user control with placesholder can do, but if...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
7
by: Electric Co. | last post by:
Hello, note: This is for a Faculty web site that is undergoing a migration to an open source solution so my motives are legit. I need to build a relay from IIS handling URL_A to a PHP server...
6
by: Water Cooler v2 | last post by:
When used with the command line interface, echo writes to the stdout, whereas in a Web environment, it writes to the response stream. How is it implemented inside PHP? Does it write to a stream?
9
by: chromis | last post by:
Hi, I've never coded in ASP before and I'm trying to port a couple of simple PHP files to ASP.NET. The first file addScores.php takes form data and a hash and inserts the data into the db, it...
1
by: junOOni | last post by:
Hello, I have a vb.net application where i am sending error string to a php page to process it. Dim errorString as String = "test string" Dim request As WebRequest =...
4
Frinavale
by: Frinavale | last post by:
Sorry for the newbie question but PHP is not my forte... I am attempting to implement a script that will retrieve a file, create a thumbnail image, and write the thumbnail to the...
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...
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
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,...
0
Oralloy
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,...
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...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.