473,946 Members | 3,803 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 2914
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
1732
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
2398
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
7504
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
6543
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
2802
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
1568
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
2060
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
13595
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
2735
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
10150
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
11142
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
11325
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
10679
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
9873
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
8240
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7404
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
6318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3526
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.