Hi
Below is the Layout . I want to check if user is authenticated only then Layout Page should open else it should go to Login Screen,
LAYOUT PAGE
<body class="hold-transition skin-blue sidebar-mini"> <div class="wrapper"> <header class="main-header"> <!-- Logo --> <a href="../../index2.html" class="logo"> <!-- mini logo for sidebar mini 50x50 pixels --> <span class="logo-mini"><b>A</b>LT</span> <!-- logo for regular state and mobile devices --> <span class="logo-lg"><b>Invoicing</b> Software</span> </a> <!-- Header Navbar: style can be found in header.less --> <nav class="navbar navbar-static-top"> <div class="navbar-custom-menu"> <ul class="nav navbar-nav"> <li class="dropdown user user-menu"> <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> <img src="images/img.jpg" alt="">John Doe <span class=" fa fa-angle-down"></span> </a> <ul class="dropdown-menu dropdown-usermenu pull-right"> <li><a href="javascript:;"> Profile</a></li> <li> <a href="javascript:;"> <span class="badge bg-red pull-right">50%</span> <span>Settings</span> </a> </li> <li><a href="javascript:;">Help</a></li> <li><a href="/Home/Logout"><i class="fa fa-sign-out pull-right"></i> Log Out</a></li> </ul> <!-- Control Sidebar Toggle Button --> <li> </ul> </div> </nav> </header> <!-- Left side column. contains the logo and sidebar --> <aside class="main-sidebar"> <!-- sidebar: style can be found in sidebar.less --> <section class="sidebar"> <!-- search form --> <form action="#" method="get" class="sidebar-form"> <div class="input-group"> <input type="text" name="q" class="form-control" placeholder="Search..."> <span class="input-group-btn"> <button type="submit" name="search" id="search-btn" class="btn btn-primary"> <i class="fa fa-search"></i> </button> </span> </div> </form> <!-- /.search form --> <!-- sidebar menu: : style can be found in sidebar.less --> <ul class="sidebar-menu" data-widget="tree"> <li class="header">MAIN NAVIGATION</li> <li class="treeview"> <a href="#"> <i class="fa fa-edit"></i> <span>Masters</span> <span class="pull-right-container"> <i class="fa fa-angle-left pull-right"></i> </span> </a> <ul class="treeview-menu"> <li><a href="@Url.Action("Index", "Location")"><i class="fa fa-circle-o"></i> Maintain Location</a></li> <li><a href="@Url.Action("Index", "Product")"><i class="fa fa-circle-o"></i> Maintain Product</a></li> <li><a href="@Url.Action("Index", "Customer")"><i class="fa fa-circle-o"></i> Maintain Customer</a></li> </ul> </li> <li class="treeview"> <a href="#"> <i class="fa fa-folder"></i> <span>Transactions</span> <span class="pull-right-container"> <i class="fa fa-angle-left pull-right"></i> </span> </a> <ul class="treeview-menu"> <li><a href="../examples/invoice.html"><i class="fa fa-circle-o"></i> Invoice</a></li> </ul> </li> </ul> </section> <!-- /.sidebar --> </aside>
<!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Main content --> <section class="content"> @RenderBody() </section> </div> <!-- /.content-wrapper --> <footer class="main-footer"> <strong>Copyright © 2021-2022 <a href="#">AdminLTE</a>.</strong> All rights reserved. </footer> </div> <!-- ./wrapper -->
<script src="~/dist/js/adminlte.min.js"></script> <script src="~/components/notify.min.js"></script>
<div id="divData"></div> </body>
Route.Config
**************
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
Home Controller *************************
public class HomeController : Controller { public ActionResult Index() { return View(); }
[HttpGet] public ActionResult Login(string ReturnUrl)
{ ViewBag.ReturnUrl = ReturnUrl; //return View(); return View(); }
}
Thanks