Home > Ask the Microsoft .Net Development Experts > ASP.NET and Web Development Questions & Answers > Accessing session variables in different pages
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Accessing session variables in different pages

Daniel Cazzulino EXPERT RESPONSE FROM: Daniel Cazzulino

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 30 December 2004
How do you access session variables in different pages of an application?

For example: I have Session("USerId") = "ABC" in page1.aspx. I go to Page2.aspx on clicking a button in page1. Can I use like this Dim sUser as string:
sUser = Session("UserId") in page2.aspx?


>
You just use them and it just works. Are you having any problem with the code you sent? By the way, you have to enable session state in the web config in order for that to work (<sessionState mode="anything but OFF"). Recall that depending on your server configuration you may need to select different values. If you have a Web Farm, InProc will only work on a single machine, and you have to ensure following requests coming from the same user are redirected to the same server that answered the first time (LocalDirector from Cisco is a well-known product for that). Otherwise, you have to either select StateServer or SQLServer to persist the session information in a central location. You can find a lot more about this and other fundamental concepts in ASP.NET in a book such as this one.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
ASP.NET
Top ASP.NET expert advice from Danny Cazzulino
Access VB .NET Windows control on client side
Drop down list server control creates error message
How to retrieve the MAC address of a client using ASP.NET
How to sort a dropdown list in ASP.NET
Automatically closing a .exe
Accessing a control on an independent application
Checking input by character to verify validity
Referencing an old Crystal Reports version
Redirecting results to a text file

ASP.NET and Web Development
Top ASP.NET expert advice from Danny Cazzulino
Access VB .NET Windows control on client side
Drop down list server control creates error message
Take care with InitializeComponent
Calling via command prompt from ASP.NET
Screen capturing
How to retrieve the MAC address of a client using ASP.NET
How to sort a dropdown list in ASP.NET
Automatically closing a .exe
Accessing a control on an independent application

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts