In ASP.NET MVC views, it's possible to call child actions like this:

@Html.Action("ActionName")

That will render the results of the action called ActionName to the output of the view.

Is it possible to make such child action call in the controller?

The output of my controller actions is JSON, not HTML, so I prepare the resulting JSON objects in the controllers instead of the Razor templates. It would be useful if I could use the same mechanism as I use when working with Razor views to render parts of the response by a child action.

I know that there's a possibility of structuring the code differently, so I could reuse the same component in two different controllers. But I want to specifically know if I can get the results of a child action in a controller the same way I can do in the view.

Related posts

Recent Viewed