I have 2 Controllers
- HomeController
- Index()
- AccountController
- Login()
In my Home/Index.cshtml I want to Load The AccountController/Login method which then returns a view and displays it in my Home/Index view.
Home/Index.cshtml
<div class="row-fluid">
<div class="col-md-12">
<!-- Render the view that the AccountController/Login method denotes -->
</div>
</div>
How do I do this?
We can use @html. action to call controller method.
The Partial Action method is decorated with ChildActionOnly attribute. The ChildActionOnly attribute is used to make sure that an Action method is only called from inside the View and cannot be access directly by the User. Generally it is used for Action methods invoked by Partial Views.
use this with your actual Controller/View names
@Html.Partial("../Home/Login", model)
or
@Html.Action("action", "controller", parameters)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With