0

I'm trying to work out why when perform a javascript AJAX call to to a Controller GET method my registered IHttpModule does not fire its events, in particular the EndRequest method. This event fires correctly when there is a standard GET request to the page the first time but not when I do this via a JQuery AJAX call.

Can anyone offer any insights here?

My javascript looks like follows:

 $.ajax({
        type: 'GET',
        dataType: "json",
        url: /controller/action,
        success: function (data) {
                //do stuff
            }
        },
        error: function () {

        }
    });

And my controller inherits from System.Web.Mvc.Controller.

In my config I have registered the module like so:

<system.webServer>

  <modules runAllManagedModulesForAllRequests="true" >
    <add name="MyWebModule" type="MyWebModule"/>
  </modules>
....
 <httpModules>
    <add name="MyWebModule" type="MyWebModule"/>
  </httpModules>
 <system.web>
Guy Lowe
  • 2,115
  • 1
  • 27
  • 37

1 Answers1

0

OK so that was a bit silly.

I had a while loop in the request that was waiting for the request to process properly.

Of course this meant that the AJAX GET request method never actually ended and therefore there was not EndRquest event fired.

Once I removed this waiting loop it fired.

Doh!

I'll answer this here just in case someone else is doing something equally silly.

Guy Lowe
  • 2,115
  • 1
  • 27
  • 37