I am trying to save value in session in webservice but it gives me error: object reference not set to an instance of an object
.
Session["ProcessStartTime"] = strDate;
I am trying to save value in session in webservice but it gives me error: object reference not set to an instance of an object
.
Session["ProcessStartTime"] = strDate;
Add (EnableSession = True)
to the WebMethod
[WebMethod (EnableSession = true)]
or Read this nice article on How to use session state in web service
strDate
not null Session["ProcessStartTime"] = strDate;
before declaration methodhere is a sample
public class mytest: System.Web.Services.WebService
{
[WebMethod (EnableSession = true)]
public string HelloWorld()
{
//your logic here
if(strDate!=null)
Session["ProcessStartTime"] = strDate;
else
// handle if ur strDate is null
}
}