In my MVC3 application, I want to remove all HTML5 tags for output when the user uses IE <9 to avoid using a workaround in the interface.
I have considered the use of the method HttpModule, ActionFilter, OnResultExecutedon the controller and inside Application_Start.
I figured out that I needed to get the output as a string from HttpApplication.Context.Response.OutputStream, using something like:
HttpApplication application = (HttpApplication)source;
HttpResponse response = application.Context.Response;
StreamReader sr = new StreamReader(stream);
string content = sr.ReadToEnd();
But all I get is the same error Stream was not readable. I can write an answer using context.Response.Write.
Reporting about SO and google, MVC does not seem to have the same “page life cycle” that it has web forms (where I just overflow Render, and it works great), which makes sense.
So my question is: how to get HTML as a string in MVC? Has anyone tried to manipulate html output?
source
share