Windows Phone 7 - Cookies not sent to WCF

I have a bunch of WCF services in a domain:

  • AuthenticationService (standard MS version, more than HTTPS)
  • AppService (HTTP)

I usually call the authentication service and a cookie is returned. For desktop applications, I disconnect the cookie and connect it every new service call in AppService, which provides the meat of my API.

Silverlight in the browser automatically attaches cookies in all calls to the domain. I expected the phone to do the same.

This is not true.

Access to headers is not supported on the phone, so there is no manual manipulation. Interestingly, because some kind of bright spark in MS thought that the phone should ensure that these cookies are only bound to HTTPS endpoints in the same domain or something like that ...

Help !!

This is a troubleshooting nightmare because the phone does not support other basic important useful settings; ignoring self-signed certificates.

Thank,

Luke

** UPDATE **

While I am using the CookieContainer method, I must indicate that even if the Add method is not in the header collection in Silverlight, you can still add headers using the indexer.

See http://cisforcoder.wordpress.com/2010/12/01/how-to-implement-basic-http-authentication-in-wcf-on-windows-phone-7/

** UPDATE 2 **

CookieContainer can be set according to Lex's answer. I am stuck now and continue to investigate the ArgumentNullException thrown from the WCF client after referring to Exferences.cs EndInvoke. My server does not show any sign of receiving a call.

Two key stack calls:

System.Net.Browser.HttpWebRequestHelper.ParseHeaders

MS.Internal.InternalWebRequest.OnDownloadFailed

, ArgumentNullException .

/SDK - . , , SSL, .

, . , , , - SDK.

, , WP7 WCF, EndpointNotFoundException ArgumentNullException, .

+3
1

SL cookie - http. WP7, .

< httpCookieContainer/" > ( ServiceReferences.ClientConfig).

http .

WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
WebRequest.RegisterPrefix("https://", WebRequestCreator.ClientHttp);

CookieContainer - .

var cc = new CookieContainer();
var service1 = new ServiceReference1.MyService1Client { CookieContainer = cc };
var service2 = new ServiceReference2.MyService2Client { CookieContainer = cc };

, cookie cookie, -. , cookie Path.

+1

Source: https://habr.com/ru/post/1777732/


All Articles