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

  • SEARCH
  • Home
  • 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 8913383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:26:52+00:00 2026-06-15T04:26:52+00:00

I click on refresh button which should restart session: protected void btnRefresh_Click(object sender, EventArgs

  • 0

I click on refresh button which should restart session:

protected void btnRefresh_Click(object sender, EventArgs e)
{

    HttpContext.Current.Session.Abandon();
    HttpCookie mycookie = new HttpCookie("ASP.NET_SessionId");
    mycookie.Expires = DateTime.Now.AddDays(-1);
    Response.Cookies.Add(mycookie);
    LblSessionID.Text = HttpContext.Current.Session.SessionID+
        " test btnRefresh_Click";
    LblIsNewSession.Text = Session.IsNewSession.ToString();
}

But when the button is clicked, the SessionID value in LblSessionID still displays the old value but another label LblIsNewSession will show it as true for IsNewSession. The LblSessionID will then reflect the actual SessionID value when I use asp.net control (like dropdown) that has autopostback="true" and from there SessionID sticks around.

I do use global.asax

Any idea why LblSessionID isn’t behaving as it should and is waiting for next postback to start reflecting actual value?

When I launch the web application, the problem is the same – LblSessionID show different value and then change after first postback and stays the same from there.

  • 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-15T04:26:53+00:00Added an answer on June 15, 2026 at 4:26 am

    That’s the way it works – If you Abandon the session it won’t reflect that until the next Request. It makes sense if you think about it…

    Say you have a user that accesses your site and gets a Session ID of 123 (not reflective of an actual value, I know). When you click your button to get a new Session ID, the user’s request is from the old Session, and that is the value that is reflected during that Request. Once the session is reset (or abandoned or whatever), the user gets a new Session ID of 321 and subsequent Request‘s will then reflect that new session ID.

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

Sidebar

Related Questions

click the button to call this method: private void goRegister(final boolean isUsername) { new
On click on next button, the list should highlight/select next item in the listview.
is there any way to create a button which will on click take you
Please check out: http://gherkin.co.nz/refresh/ and click on the purple box that says 'Membership chest'
I need to refresh my Activity once i click my Tab activity back. Currently
The click event should work fine: subMenu = $(.sub-menu) //.... subMenu.show() $(a.mobile).click (e) ->
I click the button and nothing happens. If I take out the validation code,
I have the Table with rows and when I click on add button the
I have a protected page which shows data to logged in users only, once
I have a webpage that on a button click grays out the main form

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.