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:
Response.Clear(); // Output some stuff Response.End();
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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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:
- Create new item
- Choose “Web page”
- Leave all the html-tags in there, just for fun
-
Fill the
page_loadlike thisprotected void Page_Load(object sender, EventArgs e) { Response.Write("test1"); Response.Clear(); Response.Write("test2"); Response.End(); }
It will then output “test2” without any html-tags.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0