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
}
精彩评论