If the the user is not using javascript, I will refresh the view with a RedirectToAction after an IsAjaxRequest check. This works when I have a user contrl in the page and return partial view.
BUt when I just want to return a value, say int, and also still want to use RedirectToAction when not an ajax request, how do i set up the method in the controller?
public ActionResult…
(if ajax request) Return View (new{value=5})? (if not) redirecttoAction ('view');
not working.
You need to use the JsonResult.
It will serialize the anonymous object in to a JSON result. Or if you really want to just return an ‘int’, which isn’t really common AJAX you should use the
ContentResult.