How to force an IIS hosted WCF or ASMX [webservice] to use session object readonly?

前端 未结 3 1294
星月不相逢
星月不相逢 2020-12-18 04:22

While making my first ajax attempts, I decided also, to go to use IIS hosted WCF now. The strange thing is, that the WCF cannot process several requests parallel for the sam

相关标签:
3条回答
  • 2020-12-18 04:27

    In .NET 4, you can do this in Application_BeginRequest

    if (Context.Request.Path.EndsWith("xxx.svc"))
       Context.SetSessionStateBehavior(SessionStateBehavior.ReadOnly);
    
    0 讨论(0)
  • 2020-12-18 04:36

    I found this:

    http://blogs.msdn.com/silverlightws/archive/2009/09/30/having-a-pollingduplex-service-and-any-other-wcf-service-in-the-same-website-causes-silverlight-calls-to-be-slow.aspx

    Which states,

    "All WCF services require read/write session state access if you enable ASP.Net sessions, which causes the replies to be queued sequentially. Ideally user should be able configure the WCF handler to be read only, which would allow polling duplex services to work with sessions. Unfortunately this is unsupported at this point."

    ...the only thing I can think of is if there's some way to manually force early release of the lock. I'm looking into that now.

    0 讨论(0)
  • 2020-12-18 04:45

    You can provide a custom session state provider

    See: http://koolsand.blogspot.com/2010/02/why-iis-hosted-wcf-services-does-not.html

    whenever a request contains svc in the path it intimates default session state provider to use readonly lock and not read-write lock. So using readonly lock will allow the next wcf call to be executed concurrently.

    0 讨论(0)
提交回复
热议问题