Link to home
Start Free TrialLog in
Avatar of amillyard
amillyardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

session variable / datetime

c sharp  .net

have a couple of Session Variables:

protected void Session_Start(object sender, EventArgs e)
{
    Session.Add("serverTimeAdjustment", 6);
    Session.Add("todaysDateTimeServerAdjusted", DateTime.Now.AddHours(Session["serverTimeAdjustment"]));
}

When I want to retieve this variable elsewhere in the web app, I use the following:

DateTime reportingDateTime = (DateTime)Session["todaysDateTimeServerAdjusted"];

Compiling is fine - but the debugger is then complaining when running ... and the following error on the above line:

'Object reference not set to an instance of an object.'
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amillyard

ASKER

carl_tawn: spot on ... scripting was not initialising as early as hoped !  thanks :-)