From the course: ASP.NET Core Identity: Authorization Management

Unlock the full course today

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

Analyzing handler results

Analyzing handler results - ASP.NET Core Tutorial

From the course: ASP.NET Core Identity: Authorization Management

Start my 1-month free trial

Analyzing handler results

- [Instructor] We have learned so far how to create a custom requirement's class, how to create a custom handler, and now, we are going to learn how we can define a handler status, if it was a success or a failure. A handler indicates a success by calling context.Succeed method where we pass as a parameter the requirement that has been successfully validated. So in our case we have the minimum age requirement. Handler doesn't need to handle failures generally because other handlers might succeed, but if we want to guarantee failure, then we can use the context.Fail method without passing any parameters. So now, let's go to Visual Studio and test our application. So in here, I'll just run this application, and then on the URL let us write Game/Index. We see that we get an exception, and that's right because we want to access the value property from an object which is null. And it is null because, first of all the user is not authenticated, but it also doesn't have a date of birth…

Contents