I am beginner in MVC and trying to redirect Admin into _Layout - admin.cshtml after login successfully, because I have different options in admin navbar. I have logged in and redirect the layout into _Layout - admin.cshtml successfully. But, when I clicked on Gallery option my layout again moves into the previous _Layout.cshtml. Which is not correct.
Anybody can suggest me, how can I resolve this issue?
_Layout - admin.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - SS General Trading</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
@RenderPage("~/Views/Shared/Navbar-admin.cshtml")
<div>
@RenderBody()
<hr />
<footer style="margin-top:-50px; z-index:999" class="site-footer">
<div class="row">
<div style="border-right:groove" class="col-md-4">
</div>
<div style="border-right:groove" class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
</html>
Navbar-admin.cshtml
@{ Layout = null; }
<!DOCTYPE HTML>
<html lang="en">
<head>
-------- some code
</head>
<body>
<!-- header-top -->
<div class="header-top">
------- some code
<div class="top-nav">
<nav class="navbar navbar-default">
<div class="container">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
Menu
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="home-icon"><a href="index.html"><span class="fa fa-home" aria-hidden="true"></span></a></li>
<li>@Html.ActionLink("News", "Index", "News_Events")</li>
<li>@Html.ActionLink("Gallery", "Index", "Galleries")</li>
@Html.Partial("_LoginPartial")
</ul>
</div>
<div class="clearfix"> </div>
</div>
</nav>
</div>
</div>
<!-- //container -->
</div>
</body>
</html>
_ViewStart.cshtml
@{
if (this.User.IsInRole("Admin"))
{
Layout = "~/views/shared/_layout - admin.cshtml";
}
else
{
Layout = "~/Views/Shared/_Layout.cshtml";
}
}