ASP.NET Core: Authentication

Menu
Menu

Securing Pages

Access Denied Action

In Controllers/SecurityController.cs add an Action that will be used if users are denied access:

CONTROLLER: Controllers/SecurityController.cs

Set up the Access Denied View

Set up a View of Views/Security/AccessDenied.cshtml as follows:

VIEW: Views/Security/AccessDenied.cshtml

Secure the CMS

To secure pages in Controllers/CMSController.cs add the [Authorize] attribute as follows:

VIEW: Controllers/CMSController.cs

Ensure that the Identity framework is available to the Controller.

Test the application try to access the CMS. You should again be re-directed to the SignIn paage. Currently the View/Security/SignIn does not exist. We'll do that next.