Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6122107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:51:37+00:00 2026-05-23T15:51:37+00:00

I write the following code to access the page but this is not working

  • 0

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

     <roleManager enabled="false" />
    <authentication mode="Forms">
  <forms loginUrl="Default.aspx"
timeout="20" />
</authentication>

    <sessionState mode="InProc" timeout="180"></sessionState>

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

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:51:38+00:00Added an answer on May 23, 2026 at 3:51 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i write the following code to access page JQueryPage.aspx and get data from it
I have the following code in my index.php page: // Write the resulting JSON
I know the following code can access outer this. var o = function() {
The following code does not have any errors when run script.py -f filename but
I am using following code to write in file in, but problem occurred when
I write the following code all the time to handle when the enter key
How can I write the following code quickly in emacs? \newcommand{\cA}{\mathcal A} \newcommand{\cB}{\mathcal B}
If I write the following code: session_start(); $_SESSION['user_id']='daniel'; the variable stays fine as long
When I write the following code I get garbage for an output. It is
How would I write the following C# code in F#? namespace Shared { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.