blowdart

Imperative checks in views

Aug 11th, 2015
264
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data