ASP.NET MVC: Authentication and Authorization
By Tan Lee Published on May 29, 2017 5.49K
How to Implement Authentication and Authorization, check if user is authorized inside action with ASP.NET Identity MVC 5 using C#, Entity Framework Code First
Step 1: To check user authentication and authorization you can change the HomeController as below
public class HomeController : Controller { public ActionResult Index() { return View(); } [Authorize(Roles = "Admin")]//user 1 public ActionResult About() { ViewBag.Message = "Your application description page."; return View(); } [Authorize(Roles = "Sales")]//user 2 public ActionResult Contact() { ViewBag.Message = "Your contact page."; return View(); } }
VIDEO TUTORIALS
- ASP.NET MVC Responsive Templates Free Download
- How to upload file in ASP.NET MVC
- How to Create Contact Form Flat Responsive in ASP.NET MVC
- How to check if HttpPostedFileBase is an image
- How to upload Multiple File in ASP.NET MVC
- ASP.NET MVC: Implement Password Reset with ASP NET Identity
- ASP.NET MVC: Getting Started
- ASP.NET MVC: Create Custom Routes
Categories
Popular Posts
Structured Data using FoxLearn.JsonLd
Jun 20, 2025
Implement security headers for an ASP.NET Core
Jun 24, 2025
Modular Admin Template
Nov 14, 2024
SB Admin Template
Nov 14, 2024
Carpatin Admin Dashboard Template
Nov 15, 2024