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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With