次のような Web サービス メソッドでセッションを有効にします。
[WebMethod(EnableSession=true)]
public string HelloWorld()
{
return "Hello World";
}
Cookie のないセッション状態 (web.config) を使用します。
<sessionState cookieless="true"></sessionState>
次に、次のようにクライアントから呼び出してみます。
localhost.WebService1 ws1 = new localhost.WebService1(); // the web service proxy
ws1.HelloWorld();
オブジェクトが移動されたことを示すリダイレクト WebException (302) が発生します。