This question already has an answer here:
I am developing an ASP.NET MVC 3 application, whose content pages have a common pattern of layout elements. However, because the login page does not follow this layout, I cannot place this layout in \Views\Shared\_Layout.cshtml
.
So I would like to add another shared layout, say, \Views\Shared\_Content.cshtml
, and call it from the content views... but unfortunately those views belong to different controllers.
Is there any way to invoke @Html.Partial
for a view belonging to a different controller?
As GvS said, but I also find it useful to use strongly typed views so that I can write something like
without magic strings.
That's no problem.
or
Should do the trick.
If you want to pass through the (other) controller, you can use:
or any of the other overloads