title: how to add access security to a function caused by an event in asp.net c#
body: <p>ASP.NET C#</p>
  
  <p>I have a question, how can I make an access control to a request provided by a botton, to stop the execution of the function, I need something generic in which it can be configured and say that roles or profiles can access to certain functions request Executed by a button.</p>
  
  <p>I don't want something like that</p>
  
  <pre><code> protected void DownloadFile_ServerClick(object sender, EventArgs e)
   {
       if (RoleAdmin)
         {
           // do something
         }
   }
  </code></pre>
  
  <p>I need something that directly validates in the request of the pag when the method is executed, to see if that profile matches with the method stored in the base, so I do for all pag and do not have to put it in hard in each one of the executed methods.</p>
  
  <p>I need the name of fucntion that is request.</p>
  
  <pre><code>public class PageBase : Page
  {
  
   protected override void OnLoad(EventArgs e)
      {
  
  
          ***How to capture the function name of request ???***
  
          if (User.Identity.IsAuthenticated == false) { Response.Redirect("~/Account/login.aspx?ReturnUrl=/admin"); };
          if (!(User.IsInRole("admin") || User.IsInRole("super user"))) { Response.Redirect("/"); };
  
      }
  }
  </code></pre>