Question

In a project we use PartialView and View on the same action, depending how it is called (thanks to Request.IsAjaxRequest()). But there are places where we need to render an action on a page (not ajax).

So we use the HTML helper :

Html.RenderAction(Action, Controller, routeValues)

But this kind of call should also return a PartialView and not a View. And since this seems not to be an Ajax call, we can't use the Request.IsAjaxRequest() method to determine how the request has been sent.

I would like to know if there is something that we can use that could determine if the request has been made by a Html.RenderAction call ?

Was it helpful?

Solution

I found the solution by searching through the whole Request / Controller context and finally found the property IsChildAction on the ControllerContext. This indicates if the action has been called via Html.RenderAction or via the URL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top