diff --git a/aspnetcore/security/authorization/views.md b/aspnetcore/security/authorization/views.md index c0b42206bc..2e128801cd 100644 --- a/aspnetcore/security/authorization/views.md +++ b/aspnetcore/security/authorization/views.md @@ -29,14 +29,27 @@ Once you have injected the authorization service you use it by calling the `Auth In some cases the resource will be your view model, and you can call `AuthorizeAsync` in exactly the same way as you would check during [resource based authorization](resourcebased.md#security-authorization-resource-based-imperative); +# [ASP.NET Core 2.x](#tab/aspnetcore2x) + ```csharp -@if (await AuthorizationService.AuthorizeAsync(User, Model, Operations.Edit)) + @if ((await AuthorizationService.AuthorizeAsync(User, Model, Operations.Edit)).Succeeded) {

Edit

} ``` +# [ASP.NET Core 1.x](#tab/aspnetcore1x) + +```csharp + @if (await AuthorizationService.AuthorizeAsync(User, Model, Operations.Edit)) + { +

Edit

+ } + ``` +--- + Here you can see the model is passed as the resource authorization should take into consideration. >[!WARNING]