Session Object and web.config

  • Thread starter Thread starter Bob Garbados
  • Start date Start date
B

Bob Garbados

I have an asp.net site that requires users to log in and I'm trying to
use the session object to hold the userid that is entered. Can anyone
provide or point me to an example of a full web.config file and
working code? I'm using C#

Here's where I'm trying to populate the session object:

void Page_Load(Object sender, EventArgs e)
{
id = Request.Params["salesid"];
string pwd = Request.Params["userpwd"];
Session("UserID") = id;

Here's the error message I'm getting:
CS0118: 'System.Web.UI.Page.Session' denotes a 'property' where a
'method' was expected

thanks.
 
You set session objects in C# using the following synta

Session.Add( "Key", value )

usually best to use strings for the value i.e

Session.Add( "MyValue", "This is my value")

to retrieve it us

string myValueFromSession = Session["MYValue"].ToString();
 
Back
Top