title: ASP.NET HTML Generation based on user ROLE
body: <p>I developed very simple web site, I have onle three web pages.</p>
  
  <ol>
  <li>Logon.aspx</li>
  <li>Register.aspx</li>
  <li>MyAccount.aspx</li>
  </ol>
  
  <p>Logon.aspx code:</p>
  
  <pre><code>        if (ValidateUser(email, password))
          {
              FormsAuthenticationTicket tkt;
              string cookiestr;
              HttpCookie ck;
              tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now,
                                                  DateTime.Now.AddMinutes(3), chkPersistCookie.Checked,
                                                  email + "@ticket");
              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>Register.aspx code:</p>
  
  <pre><code>    private bool RegisterUser(string name, string surname, string email, string phone, string pass)
      {
          SqlConnection conn = new SqlConnection(@"Data Source=Server\SQL;Initial Catalog=Db;Integrated Security=True; User ID=user; Password =pass;");
          conn.Open();
          string insertQuery = @"INSERT INTO Users (Email, Name, Surname, Phone, Manager, Rank, Password)
                                  VALUES (@Email, @Name, @Surname, @Phone, @Manager, @Rank, @Password)";
          SqlCommand cmd = new SqlCommand(insertQuery, conn);
  
          cmd.Parameters.Add("@Email", email);
          cmd.Parameters.Add("@Name", name);
          cmd.Parameters.Add("@Surname", surname);
          cmd.Parameters.Add("@Phone", phone);
          cmd.Parameters.Add("@Manager", "Test@Test.com");
          cmd.Parameters.Add("@Rank", "1");
          cmd.Parameters.Add("@Password", pass);
  
          try
          {
              int rowsAffected = cmd.ExecuteNonQuery();
          }
          catch (Exception e )
          {
  
              throw;
          }
          finally
          {
              cmd.Dispose();
              insertQuery = string.Empty;
          }
  </code></pre>
  
  <p>Everything is perfect. 
  Now what I want is on Page_Load of MyAccount.aspx:</p>
  
  <ol>
  <li>Get cookie </li>
  <li>Check user Role </li>
  <li>Based on user Role display required web site content.</li>
  </ol>
  
  <p>But I am not sure how to do that.</p>
  
  <ol>
  <li>Should I refer cookie to establish user role?</li>
  <li>How do I generate HTML based on user role?</li>
  </ol>
  
  <p>Thanks!</p>