开发者

How do I read the html from an HttpResponse object

I'm creating a custom module and I need to be开发者_C百科 able to read the html output that's written to the HttpResponse object. Can anyone provide direction on this?

Thanks!


I think that you could intercept the data being written with a HttpResponse.Filter.

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.filter.aspx

There is an example here:

http://aspnetresources.com/articles/HttpFilters

I have not tried it myself yet though.


As André said, you may want to implement an HttpResponse filter. Alternatively to configuring the filter in the web.config file, you can also implement the following in the global.asax.cs file:

  protected void Application_BeginRequest() {
     Response.Filter = new PassThroughFilter(Response.Filter);
  }

The PassThroughFilter class derives from Stream and implements the abstract methods, then forwards them to the original filter.

For the full source code, see my blog.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜