O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use Session State

Problem

You want to create a Web service that can store information in user-specific session state.

Solution

Avoid this option if possible because it leads to several complications. If it’s absolutely necessary to use session state, set the EnableSession property of the WebMethod attribute to True, and initialize the CookieContainer property of the proxy class before calling the Web method.

Discussion

ASP.NET Web services can use session state to store objects in server-side memory. However, this approach has several consequences, including:

  • Because session state must be tracked using a cookie with the session ID, the client must take additional steps to maintain the cookie. In addition, session state won’t work over protocols other ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required