Session Object and web.config

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.
 
G

Guest

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();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top