title: asp.net forms authentication with Role
body: <p>I have a login screen that requires a username/password.</p>
  
  <p>I am using ASP.NET's Membership and Role tables that is part of ASP.NET to store info when the user initially registered.</p>
  
  <p>Once the user logs in with the appropriate role,  then direct them to another page.</p>
  
  <p>Here is the web.config file for the that other page. Note that it only allows role of SomeRole. </p>
  
  <pre><code>    &lt;configuration&gt;
      &lt;system.web&gt;
      &lt;authorization&gt;
          &lt;allow roles="SomeRole" /&gt;   
          &lt;deny users="*" /&gt;                   
      &lt;/authorization&gt;
     &lt;/system.web&gt;
     &lt;/configuration&gt;
  </code></pre>
  
  <p>In the login screen, I capture the username, password. I am not sure though how to make the 
  following be the user's role.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>      protected void btnLogin_Click(object sender, EventArgs e)
        {    
            // not sure what code to put here so user logged in that has a Role of SomeRole works with code just below                   
            if (User.IsInRole("SomeRole"))
  </code></pre>
  
  <p>When I look to see, User's role shows up as blank. My question is, how do I make the current that is logged in have role of SomeRole so that  </p>
  
  <pre><code>    &lt;allow roles="SomeRole" /&gt;    
  </code></pre>
  
  <p>will work. Note that on the login screen, I have a user name and password that belongs to SomeRole but not sure how to make </p>
  
  <p>if (User.IsInRole("SomeRole")) work so that inherit's that user's role. Hope this make sense. </p>
  
  <p>Here is what my web.config looks like:</p>
  
  <pre><code>         &lt;roleManager enabled="true" cacheRolesInCookie="true"
                 defaultProvider="SiRoleProvider"
                 createPersistentCookie="false"
                 cookieProtection="All"&gt;
             &lt;providers&gt;
              &lt;clear/&gt;
               &lt;add connectionStringName="SiiSQL1" applicationName="SiGen" name=" r" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
               &lt;/providers&gt;
             &lt;/roleManager&gt;      
  </code></pre>
  
  <p>Thanks </p>