title: Authorize Admin Controller in ASP.Net MVC 4
body: <p>I am building a website using mvc4 and c#. I have an admin controller. I want to authenticate that controller.</p>
  
  <p>I have an SQL db table user (that contain User_NA,User_pwd, and User_role) based on the role how can I login to admin index page.</p>
  
  <pre><code>[Authorize]   
  public ActionResult Index(string id="")
  {
       ViewBag.Admin = id;
       return View();
  }
  </code></pre>
  
  <p>I have a Login and Logout Actions.</p>
  
  <pre><code>[HttpGet]
  public ViewResult Login()
  {
      return View();
  }
  [HttpPost]
  public RedirectResult Login(FormCollection form)
  {
      string uid = Request.Form["userid"];
      string pwd = Request.Form["password"];
      ...............................
      else return Redirect("~/Admin/Login");
  }
  
  public RedirectResult Logout()
  {
      System.Web.Security.FormsAuthentication.SignOut();
      return Redirect("~/Admin");
  }
  </code></pre>
  
  <p>How can I write the authentication code into login action? And is there any change in Web.Config file or any other files?</p>