From 74e22e08e3b08cb576e5184d16f4af5656c13c0c Mon Sep 17 00:00:00 2001 From: Steven Moschidis Date: Fri, 25 Aug 2017 22:01:21 +0100 Subject: [PATCH] "fix" code sample (#4061) * "fix" code sample * Update views.md * Update views.md --- aspnetcore/security/authorization/views.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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]