AJAX breaks due to HttpModule, how to stop it?

Need help with AJAX issue.

I have certain controls on an ASPX page that uses AJAX to handle async.

I also have an HttpModule for a particular site that intercepts and filters the HttpRequest.

After installing the module, the AJAX controls are broken. It seems that these controls are not coming back with AJAX Post. With this, the HttpModule code:

public void Init(HttpApplication context)
{
  context.ReleaseRequestState += new EventHandler(InstallResponseFilter);
}

public void Dispose()
{
}

private void InstallResponseFilter(object sender, EventArgs e)
{
   HttpResponse response = HttpContext.Current.Response;

   if (response.ContentType == "text/html")
   {
      response.Filter = new MyFilter(response.Filter);
   }         
}

Any ideas? Thanks

+3
source share
1 answer

Presumably your ajax answers come out with the text / html content type? Have you tried debugging to confirm this?

, - "application/json" "text/xml" , . , .

ajax, , . , , .

InstallResponseFilter, , ajax jquery (x--), , , . ajax, .

+1

Source: https://habr.com/ru/post/1790670/


All Articles