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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:00:53+00:00 2026-06-03T13:00:53+00:00

static List<string> keywordList = new List<string>(); protected void btnEnter_Click(object sender, EventArgs e) { lbxKeywords.Items.Add(tbxKeyword.Text);

  • 0
static List<string> keywordList = new List<string>();

protected void btnEnter_Click(object sender, EventArgs e)
{
    lbxKeywords.Items.Add(tbxKeyword.Text);
    keywordList.Add(tbxKeyword.Text);
    tbxKeyword.Text = string.Empty;
}

protected void btnSearch_Click(object sender, EventArgs e)
{
    Session["keywords"] = keywordList;
    keywordList.Clear();
    Response.Redirect("Results.aspx");
}

When I clear the list session become null. why is that?

thanx..

  • 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-03T13:00:56+00:00Added an answer on June 3, 2026 at 1:00 pm

    That’s because what you store in the session variable is just a reference to the list, not a copy of the list.

    Create a copy of the list for the session variable:

    Session["keywords"] = new List<string>(keywordList);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class Program { static void Main(string[] args) { List<Book> books = new List<Book> {
i have the following code: public static void Serialize() { List<string> dirs = FileHelper.GetFilesRecursive(fileDirectoryPath);
considering this example: public static void main(final String[] args) { final List<String> myList =
I have a variable declared as: private static List<String> _search_result_list = new ArrayList<String>( 15
public static List<Product> Load(string filename) { if (!File.Exists(filename)) { throw new FileNotFoundException(Data could not
I have the following snippet of code: public static List<string> sqlData = new List<string>();
For example I have: public static List<int> actorList = new List<int>(); public static List<string>
I have this bit of code, public static List<string> GetSentencesFromWords(List<string> words, string fileContents) {
Background I serialize a very large List<string> using this code: public static string SerializeObjectToXML<T>(T
I would like to assign a static list of items in a SelectList() to

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.