开发者

response.filter end of response

开发者 https://www.devze.com 2023-03-18 13:44 出处:网络
I\'m using an httpModule to create a response filter for modifiying the JSON generate开发者_StackOverflow中文版d by ASP.NET web services.

I'm using an httpModule to create a response filter for modifiying the JSON generate开发者_StackOverflow中文版d by ASP.NET web services.

In my filter I need to know when I have recieved all the JSON from the response stream so that I can then modify it.

Is there anyway to determine when the response is complete other than manually building up the response in the filter and checking it against a regular expression (which could be expensive)


Handle the EndRequest event of the HttpApplication

public void Init(HttpApplication application) {
    application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
    application.EndRequest += (new EventHandler(this.Application_EndRequest));
}

private void Application_EndRequest(Object source, EventArgs e)
{
    HttpApplication application = (HttpApplication)source;
    HttpContext context = application.Context;
    // your code here to check response
}
0

精彩评论

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