I am trying to use a Session variable in my cs file, and in the same cs file i am using ISession.
Handler page..
int ImageID = Convert.ToInt32(context.Session["ImageId"]);
cs file…
protected ISession Session
{
get { return Ioc.Resolve<IWebSessionManager>().CurrentSession; }
}
int ImagefId=objbal.GetImageID(Id);
HttpContext.Current.Session["ImageId"] = ImagefId.ToString();
as i am going to next step while debugging I am getting Object reference not set to an instance of an object. on Handler page.
and if I am trying to change in ISession Session name and HttpContext.Current.Session[“ImageId”] to Session[“ImageId”] then Session is showing the error Session does not exist in the currenct context.
Someone plz help me to solve this…
Please tell, did you make sure, you have inherited interfaces IReadOnlySessionState or IRequiresSessionState in your Handler? According to post on codedigest website ‘Object reference not set to an instance of an object.’ exception is thrown when Handler is not inherited from any of that interfaces.
Also did you make sure that state
"ImageId"is added to session states with Add method before it is accessed?