I'm using @Html.Action()
to render a child action within my view.
The _ViewStart.cshtml
file specifies that all views should use a particular layout like this:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
Problem is, that layout is getting applied to my child action too, so the final page ends up with two headers and two footers. How do I prevent this?
2 possibilities:
return PartialView()
from the corresponding controller action instead of a return View()
Blank out the layout in the view itself
@{
Layout = null;
}
Seems you want to use ChildActionOnly
and don't want to pass the model from view then you can not user PartialView.
If it is so, you need to remove the layout manually
@{
Layout = "";
}
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