ASP.NET USER ROLE Issue
<p>I am trying to establish which Role for logged user.    </p>

<p>Login.aspx:</p>

<pre><code>if (ValidateUser(password, userDetails.Rows[0]["Password"].ToString()))
        {
            FormsAuthenticationTicket tkt;
            string cookiestr;
            HttpCookie ck;
            tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now,
                                                DateTime.Now.AddMinutes(3), chkPersistCookie.Checked,
                                                userDetails.Rows[0]["Rank"].ToString(),
                                                FormsAuthentication.FormsCookiePath);
            cookiestr = FormsAuthentication.Encrypt(tkt);
            ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
            if (chkPersistCookie.Checked)
                ck.Expires = tkt.Expiration;
            ck.Path = FormsAuthentication.FormsCookiePath;
            Response.Cookies.Add(ck);

            string strRedirect;
            strRedirect = Request["ReturnUrl"];
            if (strRedirect == null)
                strRedirect = "MyAccount.aspx";
            Response.Redirect(strRedirect, true);
        }
        else
            Response.Redirect("logon.aspx", true);
</code></pre>

<p>Global.aspx:</p>

<pre><code>protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {
        if (HttpContext.Current.User != null)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (HttpContext.Current.User.Identity is FormsIdentity)
                {
                    FormsIdentity id =
                        (FormsIdentity) HttpContext.Current.User.Identity;
                    FormsAuthenticationTicket ticket = id.Ticket;

                    // Get the stored user-data, in this case, our roles
                    string userData = ticket.UserData;
                    string[] roles = userData.Split(',');
                    HttpContext.Current.User = new GenericPrincipal(id, roles);
                }
            }
        }
    }
</code></pre>

<p>Now I am trying to get User Role but it always return me false.</p>

<pre><code>        if(User.IsInRole("Manager"))
        {
            //Activate premium feature.
            BtnAddMoney.Visible = true;
        }
</code></pre>

<p>Could you guys check, what's wrong in my code?</p>
