문제

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 ?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top