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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:24:29+00:00 2026-05-13T21:24:29+00:00

I am building a Asp.net Application. I need to save a HashTable in a

  • 0

I am building a Asp.net Application. I need to save a HashTable in a session.

At page load i am writing

 protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
       Session["AttemptCount"]=new Hashtable(); //Because of this line.
    }   
}

Here problem is, when a user refresh the page, session[“AttemptCount”] also get refreshed.
I want to know where should I declare

Session["AttemptCount"]=new Hashtable();

So that my seesion do not get refeshed.

EDIT In Global.asax, this session will get started, as soon as user opens the website. I want to creat this session only if user go to a particular page. i.e Login.aspx

  • 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-13T21:24:30+00:00Added an answer on May 13, 2026 at 9:24 pm

    Do it in the Session_Start method in your Global.asax like so…

    protected void Session_Start(object sender, EventArgs e)
    {
        Session["AttemptCount"]=new Hashtable();
    }
    

    Update:

    Then simply just do a check to see if the session variable exists, if it doesn’t only then create the variable. You could stick it in a property to make things cleaner like so…

    public Hashtable AttemptCount
    {
        get 
        {
            if (Session["AttemptCount"] == null)
                Session["AttemptCount"]=new Hashtable();
            return Session["AttemptCount"];
        }
    }
    

    And then you could just call on the property AttemptCount wherever you need like so…

    public void doEvent(object sender, EventArgs e)
    {
        AttemptCount.Add("Key1", "Value1");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an asp.net mvc web application. Do I need to use captcha
I have an ASP.NET MVC application I'm building and I'm using a Master page.
I am quite new to asp.net,I am building an application where I need to
I'm building an ASP.NET application. One of the reqiurments is to limit number of
I am building as asp.net application on .net framework 4.0 and I will be
Building a new ASP.net application, and planning to separate DB, 'service' tier and Web/UI
I am building an ASP.NET web application that will be deployed to a 4-node
I am building a new asp.net MVC3 web application for reporting and I want
I am building an ASP.Net MVC 3 Web application with Entity Framework 4.1. I
I'm building an ASP .NET 2.0 (C#) based web application, which is primarily intended

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.