Are there more ways to call a partial view from the view?

0

Is there a way to call from the view to Partial View as a Url.Action or otherwise? Since I have a method in my controller that renders a partial view, but I need to call that method from my view, for example @Html.Partial("Controller", "Action")

In what way can this be achieved?

    
asked by vcasas 28.05.2018 в 22:05
source

1 answer

0

The best way you can do it is to call @Html.Action("Action", "Controller") . This will make the call directly on the controller and will not only bring the view, as Html.Partial does.

I recommend that this action that you call be of type ChildActionOnly , so that it can not be accessed from a URL.

[ChildActionOnly]
public IActionResult Get()
{}
    
answered by 29.05.2018 в 20:12