Advertisement
blowdart

Imperative checks in views

Aug 11th, 2015
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.24 KB | None | 0 0
  1. // __viewimports.cshtml
  2.  
  3. @using Microsoft.AspNet.Authorization
  4. @inject IAuthorizationService AuthorizationService
  5.  
  6. // myView.cshtml
  7.  
  8. @if (AuthorizationService.Authorize(User, "namedPolicy"))
  9. {
  10.     <p>You’re authorized</p>        
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement