Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 12, 2012 01:55 PM by sudiptabanerjee
Apr 14, 2009 04:24 PM|LINK
In my web service I need to keep track of a value called store number. I have two methods I use to attempt to do this. Both have EnableSession=true set.
Method #1 - SetStoreNbr(string StoreNum) - I call this method and pass it the value. The value is then stored in the Session variable, like this:
Session["StoreNum"] = StoreNum;
In method #2 - GetStoreNbr(), I attempt to retrieve the value from the Session variable, like so:
However, when GetStoreNbr() is called, the Session variable is null, resulting in the following error:
System.Web.Services.Protocols.SoapException: Server was unable to process request.
---> System.NullReferenceException: Object reference not set to an instance of an object.
If I execute the Web Service in the browser via the asmx file, I can execute both of these of methods just fine. GetStoreNbr() will return me the store number. Attempting to execute these methods through an ASP.NET application raises the error mentioned
I'm new to ASP.NET, so if there's a better way to do this, please feel free to mention it.
Apr 14, 2009 05:31 PM|LINK
On your [WebMethod] attribute you should add EnableSession=true
Apr 14, 2009 08:23 PM|LINK
Thanks, that's how I've had it coded, and it didn't work.
I managed to fix the problem by switching to "Application" instead of Session, but if anyone knows why Session doesn't work that would be nice.
Apr 17, 2009 06:29 AM|LINK
You can try session mode "StateServer" which needs start the "StateServer" in server.
1. Deploy the sessionState in web.config as:
<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="600"/>
2. Before starting web application, you need start StateServer Service.(Administration Tools-> Services->ASP.NET State Service->Start)
This link can lead you to know about Session State with StateServe and SqlServer:
Apr 17, 2009 07:01 AM|LINK
In your Method#1 just check whether you are able to set the value of StoreNum to session variable.
in your web config
Jul 12, 2012 01:55 PM|LINK
Working Fine, Thanks.