I had previously created a method on my base controller:
public bool IsJsonRequest() { var acceptTypes = Request.AcceptTypes; return acceptTypes != n
It checks for the X-Requested-With (HTTP_X_REQUESTED_WITH) header being set to XMLHttpRequest. This header is set by jQuery and a number of other javascript frameworks when making AJAX requests.
X-Requested-With