Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public ActionResult Index()
  2. {
  3. if (HttpContext.User.IsInRole("admin"))
  4. return RedirectToRoute("Admin");
  5. else
  6. return View();
  7. }
  8.  
  9. routes.MapRoute("Admin", "admin",
  10. new { area = "admin", controller = "Users", action = "Index" }
  11. );
  12.  
  13. public override void RegisterArea(AreaRegistrationContext context)
  14. {
  15. context.MapRoute(
  16. "admin_default",
  17. "admin/{controller}/{action}/{id}",
  18. new { action = "Index", id = UrlParameter.Optional }
  19. );
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement