How can I distinguish between requests made from RenderAction and through AJAX?

There is a useful method in ASP.NET MVC Request.IsAjaxRequestthat I can use to determine if a request is being executed through AJAX. However, the method RenderActionappears to invoke the controller / action through AJAX.

I would like calls through to RenderActionreturn View, while calls through AJAX return an object Json. Can calls be distinguished from these two sources?

EDIT : Reynolds number jim: I just call RenderActionwithin View:

In SomeView.ascx:

Html.RenderAction("Action", "AnotherController", new { id = "some ID" });
+5
source share
1 answer

, ControllerContext.IsChildAction, , RenderAction().

+5

All Articles