Maintaining Session State in .NET Web Services

Very informative article on this here: http://msdn.microsoft.com/en-us/library/aa480509.aspx and a step by step of the client side implementation here: http://support.microsoft.com/kb/816637

The short of the long is:

  • The web service must be marked with the EnableSession=true attribute.
  • On the consuming client, you must use an instance of the CookieContainer class to store the session cookie (with the unique session ID created on your first request
  • You must then re-use this instance of the CookieContainer for each subsequent call in order to maintain session state on the web service host – a logical way to do this is to add the CookieContainer instance to session state on your client (so do a get property with “session bag” null check logic
  • Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: