Response.Clear in ASP.NET 3.5

I have recently upgraded some of my web applications to ASP.NET 3.5 by installing the framework on the server and setting up my web applications acrodingly and all is well, however.

On some pages, I want to clear the current contents of the response buffer with code like this:

// Output some stuff

But this now isn’t working in 3.5 when it did in 2.0. I have also tried setting the response buffer to false but this didn’t work either.

Can anyone let me know why it isn’t working or if there is a work around?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Try setting Buffer=”True” in the Page Directive of the page and not in codebehind.

I just tried this in VS2008 on a Web Site project:

  1. Create new item
  2. Choose “Web page”
  3. Leave all the html-tags in there, just for fun
  4. Fill the page_load like this

    protected void Page_Load(object sender, EventArgs e)  

It will then output “test2” without any html-tags.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply