I write the following code to access the page but this is not working for me
if (User.Identity.IsAuthenticated)
{
if (Context.User.IsInRole("DistrictAdmin"))
{
if (!IsPostBack)
{
}
}
else
{
Response.Redirect("Default.aspx");
}
}
else
{
Response.Redirect("Default.aspx");
}
My Login check code
string RoleTypeID;
objLogin.UserName = txtUsername.Text;
objLogin.Password = txtPassword.Text;
if (objLogin.getRoles(out RoleTypeID))
{
Session["RoleID"] = RoleTypeID;
FormsAuthenticationTicket oAuthTicket = new FormsAuthenticationTicket(1, txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(20), false, RoleTypeID.ToString(), FormsAuthentication.FormsCookiePath);
string encryptoAuthTicket = FormsAuthentication.Encrypt(oAuthTicket);
HttpCookie oCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptoAuthTicket); // Name of auth cookie
if (oAuthTicket.IsPersistent) oCookie.Expires = oAuthTicket.Expiration;
HttpContext.Current.Response.Cookies.Add(oCookie);
if (RoleTypeID == "DistrictAdmin" || RoleTypeID == "CampusAdministrator" || RoleTypeID == "LPACMember")
{
Response.Redirect("LEPstudentrecords.aspx");
}
}
else
{
lblInvalid.Visible = true;
}
and in my web.config i set as follows
But i am unable to get the role even if he is authenticated can any one tell what to do
Here is the image after authenticated every thing is getting right but i am unable to access that page
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)