Friday 25 July 2014

Restrict a Method To Members of Certain Roles

Simple Example

// Only Let People who are in the Administrator or Managers Roles Use this method
   [Authorize(Roles = "Administrator,Managers")]
        public ActionResult Delete(int id = 0)
        {
            Report Report = db.Report.Find(id);
            if (Report == null)
            {
                return HttpNotFound();
            }
            return View(Report );
        }

No comments: