Determine if Call to Action is from a View
Is there a way to determine if a call to a controllers action is from a view using the Html.Re开发者_开发问答nderAction function.
This is similar to Request.IsAjaxRequest. If the call comes from a view I would like to just render a partial view rather than the the full view with master page.
BTW Render partial is not a viable solution as the action fetches additional data
Using the ControllerContext.IsChildAction has the given effect. this way I can provide the same HTML using a child action and a ajax request (for fallback on non javascript users)
if (Request.IsAjaxRequest() || ControllerContext.IsChildAction)
return PartialView("ViewName", results);
精彩评论