Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 same user/session, if sessionmode is enabled! If sessionmode is disabled on asp.net, the requests are processed parallel. The broser/client may execute several different requests, where some of them are long running. This blocks all further requets and make my ajax app unusable.

This applies to asmx [webservices] also. I had a big hope, to compile the webservice methods using "IReadOnlySessionState" interface, but this has - in oppsite to webpages - no influence. But I need access [most times readonly] to the asp.net session!

Does someone knows any solution to this problems.

Anyway, thanks a lot!

br--mabra

like image 616
mabra Avatar asked Aug 12 '09 23:08

mabra


1 Answers

In .NET 4, you can do this in Application_BeginRequest

if (Context.Request.Path.EndsWith("xxx.svc"))
   Context.SetSessionStateBehavior(SessionStateBehavior.ReadOnly);
like image 64
Cine Avatar answered Nov 20 '22 09:11

Cine