MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet
Author Message
kellygreer1



Joined: 17 Nov 2007
Posts: 2

PostPosted: Wed Dec 12, 2007 3:30 pm    Post subject: PHP's output buffer and ASP.NET's Response.OutputStream Reply with quote

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

Archived from group: microsoft>public>dotnet>framework>aspnet
Back to top
View user's profile Send private message
"John Timney \



Joined: 28 Sep 2007
Posts: 5

PostPosted: Thu Dec 13, 2007 12:02 am    Post subject: Re: PHP's output buffer and ASP.NET's Response.OutputStream Reply with quote

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


"kellygreer1" wrote in message @p69g2000hsa.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
> kellygreer1@nospam.com
> replace nospam with yahoo
Back to top
View user's profile Send private message
kellygreer1



Joined: 17 Nov 2007
Posts: 2

PostPosted: Wed Dec 12, 2007 7:28 pm    Post subject: Re: PHP's output buffer and ASP.NET's Response.OutputStream Reply with quote

On Dec 12, 2:02 pm, "John Timney \(MVP\)"
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/asptodayarchive/73666/enforcing-xhtml-com...
>
> Regards
>
> John Timney (MVP)http://www.johntimney.comhttp://www.johntimney.com/blog
>
> "kellygreer1" wrote in message
>
> @p69g2000hsa.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
Back to top
View user's profile Send private message
"John Timney \



Joined: 28 Sep 2007
Posts: 5

PostPosted: Thu Dec 13, 2007 3:41 am    Post subject: Re: PHP's output buffer and ASP.NET's Response.OutputStream Reply with quote

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 News List
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", "TEXT");
// write the new html to the page
writer.Write(html);
}

Regards

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



"kellygreer1" wrote in message @l1g2000hsa.googlegroups.com...
> On Dec 12, 2:02 pm, "John Timney \(MVP\)"
> 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/asptodayarchive/73666/enforcing-xhtml-com...
>>
>> Regards
>>
>> John Timney (MVP)http://www.johntimney.comhttp://www.johntimney.com/blog
>>
>> "kellygreer1" wrote in message
>>
>> @p69g2000hsa.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

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
How do I get the backing buffer for a Bitmap? I'm using a Bitmap to load an image from disk - but I'm going to use OpenGL to display it. So I want a flat memory buffer that contains all the pixel information. Is there any way to get access to the raw buffer for the Bitmap? Right now I walk across the

Values in memorystream buffer confusing See code below mDifImage is 8-bit indexed How can I calculate what value to set sz to? I look at buffer expecting it to start with 14 bytes or 40 bytes but I see 13 bytes of mostly 2=digit values followed by many 3-digit

buffer overrun when playing Quicktime movies hi. I receive an error message MS Visual C++ runtime library error and it lists as causing the corruption. The error occurs after approx 10 sec's after playing any quicktime movies. I have scanned averything. De/Reintalled quicktime ve

Buffer.BlockCopy and very long arrays (more than Int32.MaxVa Hi, Anybody has ever needed to copy a very long array (more than elements) on x64? I found this solution private static void src, long srcOffset, T[] dst, long dstOffset, long count) { if (srcOffset < Int32.Max

setting a socket receive buffer size not supported on ppc2k2 Hi I use the following line in my code to increase the socket buffer size to ensure that packets sent from a server won't be dropped because the buffer fills up and the application isn't emptying the receive buffer fast enough.
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group