in Education by
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)

1 Answer

0 votes
by
You are adding the role string as 'UserData' to the FormsAuthenticationTicket. There is no magic that will infer this value to a role. I suggest you consult the documentation again. http://msdn2.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.formsauthenticationticket See http://www.codeproject.com/KB/web-security/formsroleauth.aspx for an example without RoleManager.

Related questions

0 votes
    I write the following code to access the page but this is not working for me if (User.Identity. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I have an XSLT like this: In the second template, which matches nodes in the fooDocument.xml which is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have an XSLT like this: In the second template, which matches nodes in the fooDocument.xml which is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I'm using TensorFlow Alpha 2.0. I have TFRecords files I'm reading from, each one holding a short ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    In my XSLT stylesheet I extract the value of the current month using a month-from-dateTime like this . ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I have an XML with Text elements that can include tagged text and depending on the elements attribute value ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I have an XML and would like to : sort on employeeNumber, and for each bookingtime by year, month ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    I've created a seperate assembly with a class that is intended to be published through wmi. Then I' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have a problem with Spring and JPA. Basically I try to use JPA with Spring with a pure approach ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    Visual Studio 2005 .Net Framework 2.0 I have the AjaxControlToolkit within my web application bin folder ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I'm trying to access my .xml file in the ClientBin with no success. code: WebClient xmlClient = ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    I have followed through some of the threads discussing ouput escaping in XSLT but none seesm to address the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have followed through some of the threads discussing ouput escaping in XSLT but none seesm to address the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have an ASP.NET MVC website. In my backend I have a table called People with the following ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    Details: We are using Keycloak authentication server with Asp.Net WebAPI. Now I need to get the Keycloak ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
...