Last active
July 1, 2016 14:51
-
-
Save rexcfnghk/169bf771e51278998544ace938d3907c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AdminController : Controller | |
| { | |
| public ActionResult Index() | |
| { | |
| // In real production code you should probably use the AuthorizeAttribute | |
| // instead of authorizing/forbidding the user inside an action method | |
| var user = (UserProfile)ViewBag.User; | |
| if (!user.IsAdmin) | |
| { | |
| return new HttpStatusCodeResult(HttpStatusCode.Forbidden); | |
| } | |
| return View(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment