Response.Clear in ASP.NET 3.5

I recently upgraded some of my web applications to ASP.NET 3.5 by installing a framework on the server and customizing my web applications, but all is well.

On some pages, I want to clear the current contents of the response buffer using code as follows:

Response.Clear(); // Output some stuff Response.End(); 

But now it does not work in 3.5, when it was in version 2.0. I also tried setting the response buffer to false, but that didn't work either.

Can someone tell me why it is not working, or if there is work?

+6
source share
1 answer

Try setting Buffer = "True" in the page page directive, not in code.

I just tried this in VS2008 in a website project:

  • Create new item
  • Select "Webpage"
  • Leave all the html tags there just for fun
  • Fill page_load as follows

     protected void Page_Load(object sender, EventArgs e) { Response.Write("test1"); Response.Clear(); Response.Write("test2"); Response.End(); } 

Then it will output "test2" without any html tags.

+12
source share

All Articles