title: Securing ASP.NET Web Forms page with ASP.NET Identity
body: <p>I am developing small department-size application using Web Forms. Technology choice comes form the past, as application is based on an old one already existing + Web Forms seem to be extremely fast and efficient for our case.</p>
  
  <p>Default template in VS 2015 creates all login pages, etc. I assign roles to users. And the question comes how to protect specific folder or page to be available only for users with specific role?</p>
  
  <p>The only idea I have is:</p>
  
  <pre><code>If Not Page.User.Identity.IsAuthenticated or Not Page.User.Identity.IsInRole("MyRole") Then
    Response.Redirect("~/Account/Login?ReturnUrl=" &amp; Server.UrlEncode(Request.Url.ToString())
  End If
  </code></pre>
  
  <p>This is not convenient having many pages in application. I saw MVC solves this with attribute</p>
  
  <pre><code>[Authorize( Roles = Constants.ADMIN )]
  </code></pre>
  
  <p>What is the best way to achieve this? Please advise.</p>