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 8937355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:23:56+00:00 2026-06-15T10:23:56+00:00

I am coding an ASP.NET website with C# and Entity Framework. I stored into

  • 0

I am coding an ASP.NET website with C# and Entity Framework.

I stored into a session a Login class I created. The class contains information such as the NetID, the Roles available to the user, and the role the user selects to login as.

The problem I am encountering is that whenever I try to get the information that is stored in the session inside of a Button_Click event, it seems to not get the information. I do not know if this is allowed. However, I also put the Login variable that contains the user information as public variable for any function inside the partial class to access and I still have the same problem accessing the information inside a Button_Click event. When I get the Session information inside the Page_Load event, I am able to get the values that were placed inside that Session.

The following is the code of my program.

public partial class Private_HomePagePortal : System.Web.UI.Page
{

Login SysUser = new Login();

protected void Page_Load(object sender, EventArgs e)
{
    string[] Roles;

    SysUser.Ticket = Request.QueryString["casticket"];
    SysUser.GetNetID();

    if (SysUser.Authenticate(SysUser.NetID))
    {

        SysUser.GetRoles(SysUser.NetID);
        Roles = SysUser.Roles;

        CasOut.Text = "Welcome <b>" + SysUser.NetID + "</b>!  You are now Logged in!  " + "Please choose a role you would like to sign in as." + "<br>" + "<br>";

        foreach (string item in Roles)
        {
            if (item == "Admin")
            {
                Admin.Visible = true;
                Admin.CssClass = "btn btn-danger";
                AdminBreak.Text = "<br><br>";
            }
            if (item == "SuperAdmin")
            {
                SuperAdmin.Visible = true;
                SuperAdmin.CssClass = "btn btn-danger";
                SuperAdminBreak.Text = "<br><br>";
            }
            if (item == "Member")
            {
                Member.Visible = true;
                Member.CssClass = "btn btn-danger";
                MemberBreak.Text = "<br><br>";
            }
            if (item == "Convener")
            {
                Convener.Visible = true;
                Convener.CssClass = "btn btn-danger";
                ConvenerBreak.Text = "<br><br>";
            }
            if (item == "ITAdmin")
            {
                ITAdmin.Visible = true;
                ITAdmin.CssClass = "btn btn-danger";
            }
        }
       else
        CasOut.Text = "You are not in the IUCommittee System!!!!  If you believe this is an error, contact the IT Administrator for assistance.";

    Session["Login"] = SysUser;
    Login User = (Login)Session["Login"];                           //Used to test information is actually in the Session
    CasOut.Text = User.NetID;
}

    protected void Admin_Click(object sender, EventArgs e)
{
    Login User = (Login)Session["Login"];
    User.SelectedRole = "Admin";
    CasOut.Text = User.NetID + User.SelectedRole;
    Session["Login"] = User;
}
}

I would greatly appreciate the help.

  • 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-06-15T10:23:58+00:00Added an answer on June 15, 2026 at 10:23 am

    Page_Load code will be executed each time when you press the button and in that case value of QueryString value will be erased.

    Be ensure that code in page_load gets executed once per page postback (use IsPostBack) or something like:

    protected void Page_Load(object sender, EventArgs e)
    {
      if(Session["Login"]==null)
       {
         string[] Roles;
         ....
         CasOut.Text = User.NetID;
        }
    }
    

    OR

    protected void Page_Load(object sender, EventArgs e)
    {
      if(!IsPostBack)
       {
         string[] Roles;
         ....
         CasOut.Text = User.NetID;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to develop a website in ASP.NET with C# as the coding
I am currently looking into devloping an ASP.NET website. I have configured IIS7 on
How to realize adding a new page in the asp.net mvc website without coding.
I've created a website for a client of mine. It is coded in ASP.NET
Coding Platform: ASP.NET 4.0 WebForms with C# We have a website with the existing
Is there anything I can do while coding in Asp.net to make my website
I'm jumping into updating an ASP(.NET) website coming from a PHP background and am
I'm trying to use sub-domains in my ASP.NET website but I'm coming across a
I am using visual studio 2008 coding asp.net.vb I have 20 images on my
Coding Platform ASP.NET 4.0 WebForms on IIS7.5 If I request a page blahblah.aspx which

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.