How to trigger a controller action from my view using Razor?

I have 2 controllers

- HomeController - Index() - AccountController - Login() 

In my Home / Index.cshtml, I want to load the AccountController / Login method, which then returns the 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 to do it?

+7
c # asp.net-mvc razor
source share
1 answer

use this with your actual controller / view names

 @Html.Partial("../Home/Login", model) 

or

 @Html.Action("action", "controller", parameters) 
+20
source share

All Articles