2006-09-19

Output Stream Filtering

I was debating today whether to use an output filter to replace special macros in the my site templates at runtime. Apart from the issues outlined in this article, where the filters dont run if End() is called and in some transfer and redirect methods, the process wouldn't work if i was using the visual studio design editor. Say for example that i was replacing the application root path with a macro like [[AppRoot]].
My prefered method would be to have a helper static class that references HttpContext.Current in runtime and something else a design time. Then use <%= HtmlHelper.AppRoot %> in templates instead.
Remember to wrapper the script tags in an asp:PlaceHolder if you get the can't add to controls collection error.