2009-09-09 35 views

回答

5

這可能是我:-)默認情況下,您的服務和使用的綁定將確定會話是否進場。

如果你什麼也沒做,並且使用wsHttpBinding,你將有一個會話。如果你想避免這種情況,你應該:

  • 切換到另一個協議/綁定酌情
  • 與SessionMode屬性

裝點您的服務合同,如果你想停止從永遠的服務使用會話,你可以這樣做是這樣的:

[ServiceContract(Namespace="....", SessionMode=SessionMode.NotAllowed)] 
interface IYourSession 
{ 
.... 
} 

,您可以用適當的instance context mode屬性修飾你的服務類:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] 
class YourService : IYourService 
{ 
    .... 
} 

有了這個,你應該非常安全,不會有任何會話。

Marc

+0

是的,就是你。謝謝! – 2009-09-09 13:42:39

+2

+1有用的默認wsHttpBinding信息。接口應該讀取'IYourService'而不是'IYourSession'嗎?我試圖將兩個樣本鏈接在一起:)謝謝! – 2010-04-14 12:47:37

+0

(對於wshttpbinding)serviceThrottling的SessionMode.NotAllowed和maxConcurrentSessions之間的關係如何?也許maxConcurrentSessions指出不必驗證客戶端代理的安全上下文和SessionMode.NotAllowed指向無狀態服務。 – Gerard 2011-07-20 13:06:07

相關問題