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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:00:37+00:00 2026-06-15T14:00:37+00:00

I was wondering how to go about setting up a single global variable which

  • 0

I was wondering how to go about setting up a single global variable which would be easily accessible for commands in all webpages of an ASP.net website.

Would this be done through a class, and how would I go about calling it?

An example being holding a unique user ID but being able to use that ID for SQL queries on all webpages.

  • 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-15T14:00:38+00:00Added an answer on June 15, 2026 at 2:00 pm

    It really depends on the specific scenario. You have a wide range of options that will give you different behaviors.

    Usually for ID’s that become parameters of commands, you would include those as query string parameters when generating the link to convey them between pages. I.e. if you had an admin page for editing users, you might generate a list of links with URL’s like:

    /Users/Edit.aspx?userID=123
    /Users/Edit.aspx?userID=789
    

    For the current user’s ID, that should be provided by your authentication mechanism. For example(maybe different for your scenario depending on how you authenticate):
    ASP.NET Membership: Where is Current User ID Stored?

    From there, any other user level information could be in tables related to the user ID via foreign key.

    Session[] is good for temporary storage for the current user. The reason it should be considered temporary is it will expire or be lost if the application pool is recycled. In which case it’s usually fine, because the user will have to relogin and start over wherever they were at anyhow. Just don’t store anything really important.

    You can use static classes+static property to store system wide information.

    I would avoid cookies as a last resort. The only cookies involved in any of my apps are the ones that the authentication framework creates automatically, and I never touched them directly. There’s a lot of scenarios you have to consider regarding malicious manipulation of cookies, either by the user or by a third party.

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

Sidebar

Related Questions

I am wondering the best way about setting up asp.net membership in sql server
Hay, i was wondering how i would go about setting up django so that
I have a SplitContainer and was wondering how I would go about setting a
i was wondering, how would i go about setting up a php code such
We have a single page application which loads all content through ajax calls to
Here's the setting I'm talking about: I'm wondering if I can change the Exposé
Just wondering about the performance impact of copying very large php variables. For example
Just wondering about this code below... when I turn off my internet connection and
Just wondering about some practice about this; I have made a simple visual C#
I have been wondering about how people manage their strings if they are likely

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.