Encosia - ASP.NET, AJAX, jQuery, and more

I have seen the future of web development, and it is good

Angular, ASP.NET, JavaScript By . Updated November 15, 2015

I attended a pair of inspiring presentations at Microsoft’s MVP Global Summit last week that I would have had to keep private in years past. This year was different though. Since essentially everything ASP.NET is open source now anyway, the folks on the ASP.NET team were able to not only live stream sessions from the summit, but are even hosting recordings of them on Channel 9.

Knowing that the sessions were recorded and that the content wasn’t under NDA, I’ve been eagerly looking forward to sharing videos of these two talks with you as soon as they were available.

Click here to read the rest of this post »

Making Angular’s $http work with Request.IsAjaxRequest()

AJAX, Angular, JavaScript By . Posted May 7, 2015

A question that I see come up often is why Angular’s $http AJAX methods seem to be incompatible with server-side features in popular frameworks like ASP.NET MVC, Express, Django, and Rails that modify their responses for AJAX-based requests.

Examples range from partial rendering techniques like Rails’ Turbolinks (aka UpdatePanel 2.0) to endpoints that respond with nothing but a JSON representation of the page’s content instead of rendering HTML at all. A wide range of these sort of server-side features in various frameworks and libraries work that way, so the discrepancy between the behavior in Angular vs. client-side libraries like jQuery can be puzzling.

In this post, I’ll briefly explain the mechanism that your server-side framework uses to detect AJAX requests, show you how to make a single Angular $http request compatible with that mechanism, expand that to automatically apply to all requests sent through any $http method, and then explain why Angular doesn’t seem to work right by default.

Click here to read the rest of this post »