jbrahy
asked on
what is the best way to test if a session key exists?
what is the best way to test if a session key exists?
string name = Session.Contents["name"].T oString();
that throws an exception if that value is not set.
What's the best practice in implementing this?
thanks,
John
string name = Session.Contents["name"].T
that throws an exception if that value is not set.
What's the best practice in implementing this?
thanks,
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
more explicitly
if (null == Request["name"])
{
//set a default value
name = string.empty;
}
else
{name = Request["name"].ToString() ;}
if (null == Request["name"])
{
//set a default value
name = string.empty;
}
else
{name = Request["name"].ToString()
string name ="";
if(Session.Contents["name"
{
name = Session.Contents["name"].T
}