Please help me with this action filter.
I think i need to use OnResultExecuted method
How can i have access to otput html and replace something in them?
thank you.
Please help me with this action filter.
I think i need to use OnResultExecuted method
How can i have access to otput html and replace something in them?
thank you.
How about using a whitespace removal HTTP module? It's simple to implement, clean and reusable...
http://madskristensen.net/post/A-whitespace-removal-HTTP-module-for-ASPNET-20.aspx
As with any generic whitespace removal solution though, it can easily introduce errors by removing white space where it is required. It wouldn't take long to give it a try though. :-)
Edited after comments
This will not work with .aspx files out of the box so you'll need to change the context_BeginRequest to the following...
I would like to extend Russel's solution. In MVC or i guess everywhere in beginrequest event the Response.ContentType is "text/html" since we don't know what we will answer. I founf another event where the content is defined and the filter is applyable: PostReleaseRequestState
http://www.4guysfromrolla.com/articles/120308-1.aspx
Now I see what you want to do. And I think I might have a solution. I have used parts of this approach in a output cache solution a while back, so I think it will work.
First you need your own stream class that looks like this:
And then you do something like this in your action filter:
I would consider it a little bit of a hack solution. But I haven't seen anything that isn't.