473,831 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP's output buffer and ASP.NET's Response.Output Stream

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.Output Stream.
I keep getting the error:
Exception Details: System.Argument Exception: Stream was not readable.
On this line:
StreamReader sr = new StreamReader(Re sponse.OutputSt ream, 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*********@nos pam.com
replace nospam with yahoo
Dec 12 '07 #1
3 2903
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
"kellygreer 1" <ke*********@ya hoo.comwrote in message
news:1a******** *************** ***********@p69 g2000hsa.google groups.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.Output Stream.
I keep getting the error:
Exception Details: System.Argument Exception: Stream was not readable.
On this line:
StreamReader sr = new StreamReader(Re sponse.OutputSt ream, 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*********@nos pam.com
replace nospam with yahoo

Dec 12 '07 #2
On Dec 12, 2:02 pm, "John Timney \(MVP\)"
<xyz_j...@timne y.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
response.filter method

http://microsoft.apress.com/asptoday...cing-xhtml-com...

Regards

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

"kellygreer 1" <kellygre...@ya hoo.comwrote in message

news:1a******** *************** ***********@p69 g2000hsa.google groups.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.Output Stream.
I keep getting the error:
Exception Details: System.Argument Exception: Stream was not readable.
On this line:
StreamReader sr = new StreamReader(Re sponse.OutputSt ream, 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...@nos pam.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.Output Stream? 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(HtmlText Writer writer) {
// extract all html and override <h2>News List</h2>
System.IO.Strin gWriter str = new System.IO.Strin gWriter();
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("t ext", "<h2>TEXT</h2>");
// write the new html to the page
writer.Write(ht ml);
}

Regards

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

"kellygreer 1" <ke*********@ya hoo.comwrote in message
news:38******** *************** ***********@l1g 2000hsa.googleg roups.com...
On Dec 12, 2:02 pm, "John Timney \(MVP\)"
<xyz_j...@timne y.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
response.filte r method

http://microsoft.apress.com/asptoday...cing-xhtml-com...

Regards

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

"kellygreer1 " <kellygre...@ya hoo.comwrote in message

news:1a******* *************** ************@p6 9g2000hsa.googl egroups.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.Output Stream.
I keep getting the error:
Exception Details: System.Argument Exception: Stream was not readable.
On this line:
StreamReader sr = new StreamReader(Re sponse.OutputSt ream, 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...@nos pam.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.Output Stream? 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
1723
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 is the my test. How: Create a HTML page with 2 hyper links to these files (posted below). Right click, Save target As. Tested: On my P4 1.6 GHz , 1 GB Ram server, Windows 2000 IIS 5 and Apache 1.3 for win32, 100 Mbps LAN Sample Size: 150 MB...
4
2393
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 I want to generate a image and output to client directly, then I cann't set the imageurl. I want to know if there is anyway that I can display this image to user in some place of my web page. thanks
3
7490
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 on her local machine. Everything looks pretty good. OpenLDAP/cygwin works great. PostgreSQL works great. Apache runs. PHP runs. But when I try to connect to my PostgreSQL server using PHPPgAdmin, I
1
6518
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" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
7
2793
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 (URL_B), get the content from the PHP server (if it exists) and then serve it out via IIS. If the content does not exist then I need to pass the request through to the IIS server and serve the pages from there. All of this needs to be done...
6
1564
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
2055
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 returns error or success depending on the success of the query. This is then used by a third party piece of software. My first problem is how to retrieve the result of an insert query to see if the query is successful or not: PHP Version: //...
1
13577
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 = WebRequest.Create("index.php") request.Method = "POST"
4
2729
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 "Response.OutputStream". The thing is that I don't think that such a thing exists in PHP and so I'm a bit lost. How do I write the file (as bytes) directly to the response? This is what I have so far.... // load image and get image size $img =...
0
9794
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
9642
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
10778
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10496
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...
0
10210
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
9319
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...
1
4419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3077
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.