Jimmyt1988
Jimmyt1988

Reputation: 21176

How do I call a controller action from within 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 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?

Upvotes: 11

Views: 56508

Answers (1)

Kamil Budziewski
Kamil Budziewski

Reputation: 23117

use this with your actual Controller/View names

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

or

@Html.Action("action", "controller", parameters)

Upvotes: 31

Related Questions