Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glimpse not capturing ajax calls

I have an ASP.NET MVC5 single page web application that uses angularjs to make ajax calls to an ASP.NET Web API 2 application, all of them being visible in the Chrome developer tools Network tab. However, Glimpse does not capture the ajax calls, neither in HUD, nor in the Ajax tab. I've added application/json to the glimpse content types in web.config. I also added the X-Requested-With header to my angularjs ajax calls:

$httpProvider.defaults.headers.common = { 'X-Requested-With': 'XMLHttpRequest' };

Yet the HUD keeps showing 0 ajax requests, and there is nothing in the Ajax tab. Is there anything else I should do? How can I troubleshoot this?

like image 814
Leonid Levin Avatar asked Mar 19 '23 02:03

Leonid Levin


1 Answers

I know this is an old question but the following in web config worked for me:

<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
    <runtimePolicies>
      <statusCodes>
        <add statusCode="201" />
        <add statusCode="202" />
        <add statusCode="203" />
        <add statusCode="204" />
        <add statusCode="404" />
      </statusCodes>
    </runtimePolicies>
</glimpse>

Also Glimpse identifies AJAX calls by the X-Requested-With: XMLHttpRequest header. AngularJS $http calls do not include this header by default, so they do not show up in the AJAX panel in Glimpse. We can change the defaults on $httpProvider to always add this header…

app.config(['$httpProvider', function ($httpProvider) {
    $httpProvider.defaults.headers.common = { 'X-Requested-With': 'XMLHttpRequest' };
}]);

Source: http://anthonychu.ca/post/getting-angularjs-http-and-web-api-to-work-with-glimpse (note incorrect case in the example at the link, use the above instead)

like image 189
brahnp Avatar answered Apr 05 '23 00:04

brahnp