Determine if the call refers to an action from a view

Is there a way to determine if the invocation of the action of the controllers is from the view using the Html.RenderAction function.

This is similar to Request.IsAjaxRequest. If the call comes from a view, I would just like to make a partial view, not a full view with the main page.

BTW Partial rendering is not a viable solution because the action retrieves additional data

+6
model-view-controller html-helper
source share
1 answer

Using ControllerContext.IsChildAction has this effect. that way I can provide the same HTML using a child action and an ajax request (for backing up to a user without javascript).

if (Request.IsAjaxRequest() || ControllerContext.IsChildAction) return PartialView("ViewName", results); 
+9
source share

All Articles