Share ASP.NET Session Id between WCF and a Silverlight Http client -
i have wcf service configured use asp.net session state. have tested wcf service wpf client , session state maintained across different web requests.
now trying use same wcf service silverlight app uses new http stack independent browser. need use stack in order able understand our wcf service faults. problem in case not able read responses set-cookie header asp.net_sessionid cookie or set cookie header in requests.
this binding silverligth application:
<custombinding> <binding name="customhttpbinding_ibasoawebservice" sendtimeout="01:00:00"> <binarymessageencoding /> <httpcookiecontainer /> <httptransport maxbuffersize="2147483647" maxreceivedmessagesize="2147483647" /> </binding> </custombinding> and binding of wcf service:
<basichttpbinding> <binding name="basichttp" closetimeout="01:00:00" opentimeout="01:00:00" maxbufferpoolsize="2147483647" maxreceivedmessagesize="2147483647" receivetimeout="01:00:00" sendtimeout="01:00:00" allowcookies="false"> <readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647" maxarraylength="2147483647" maxbytesperread="2147483647" maxnametablecharcount="2147483647" /> <security mode="none" /> </binding> </basichttpbinding> in silverlight application using code read set-cookie header in response:
ihttpcookiecontainermanager cookiemanager = channel.getproperty<ihttpcookiecontainermanager>(); if (cookiemanager.cookiecontainer == null) cookiemanager.cookiecontainer = new cookiecontainer(); uri applicationuri = new uri(application.current.host.source, "../"); string cookiestring = cookiemanager.cookiecontainer.getcookieheader(applicationuri); parsecookiestring(cookiestring); and code set asp.net session id cookie in request:
ihttpcookiecontainermanager cookiemanager = channel.getproperty<ihttpcookiecontainermanager>(); if (cookiemanager.cookiecontainer == null) cookiemanager.cookiecontainer = new cookiecontainer(); uri applicationuri = new uri(application.current.host.source, "../"); cookie cookie = new cookie("asp.net_sessionid", aspnetsessionid); cookiemanager.cookiecontainer.add(applicationuri, cookie); checking through fiddler messages exchanged see wcf service sends correctly set-cookie header in first response, silverlight not able read it. have tried set cookie header in request through cookiecontainer class, no luck. cannot see in fiddler.
coould give me advice must doing wrong?
many in advance.
jose antonio arroba
in web application, use uri set sessionid. (i think it's possible wcf service)
in web.config of service, define :
<system.web> <sessionstate cookieless="true"></sessionstate> </system.web> or
<sessionstate cookieless="useuri"></sessionstate> the sessionid appaears :
http://localhost:51358/(s(1wnqb23d2qe4blfxzukligdo))/default.aspx you can , set sessionid in uri.
Comments
Post a Comment