From the course: ASP.NET MVC 5 Identity: Authentication and Authorization

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

View-based authorization

View-based authorization

From the course: ASP.NET MVC 5 Identity: Authentication and Authorization

Start my 1-month free trial

View-based authorization

- [Narrator] To prevent unprivileged users from seeing certain parts of our application, or using certain services, we can restrict them in different levels. In ASP.NET MVC 5 we can restrict them from controller, action, or view level. The easiest to check if a user is authenticated is by using the user clause which returns an I principle. If you dive deeper into this interface, you will see that it has a method and a property. The identity property of type IIdentity interface helps us understand more about the logged-in user that makes the request. The IsInRole method is used to check if a user belongs to a role and has a parameter that gives a role name in a string format. IIdentity interface comes with different properties. Name returns the name of the user. Authentication type returns the authentication used to identify the user and IsAuthenticated property will return true if the user is authenticated and false otherwise. Let us now go back to index dot C Sharp HTML and see how…

Contents