开发者

How to modify raw HTML of ASP.NET page on PreRender?

I want to access the raw HTML code that my ASP.NET System.Web.UI.Page is about to render.

How can i do that? Is there a property or method like System.Web.UI.Page.HTML or something like that.

I know I could loop through the Controls List of the page and get access to all the Literal Controls etc, but I was wondering if there's a direct property or method that can return me 开发者_StackOverflow社区the raw html, which I can modify just before rendering the page.


First of all, on PreRender, the page has not yet been Render'd, so there would be no HTML.

Second, look at the HttpResponse.Filter property.


You can also use HTTPModules to make changes or just observe content inside the HTTP Pipeline. This would allow you to do things that are not necessarily the concern of the main application. Aside from providing additional layers for your application architecture, this can be handy for injecting changes after a product has gone to production since the main application itself does not necessarily have to be made aware of the changes (although that depends on which config you register the module in).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜