Unable to send cookies with RestSharp on Windows Phone

290 views
Skip to first unread message

Espen H.

unread,
Jul 2, 2011, 6:40:08 PM7/2/11
to RestSharp
I am having some problems getting my cookies added to the request I am
sending ... When viewing the request on the receiving end, there is no
cookies sent...

Code and some further explaination is available at:

http://stackoverflow.com/questions/6557058/unable-to-send-cookies-with-restsharp-on-windows-phone

I am using RestSharp 101.3 on .Net 4 (i believe, i am new to Windows
Phone but have experience from Java and C# on other platforms). Any
help would be really nice :)

Christopher Ward

unread,
Jul 3, 2011, 7:03:30 AM7/3/11
to rest...@googlegroups.com
Hi,

I had exactly the same problem. It appears the cookies don't actually get added to the request. I am doing some investigation to this, but as an immediate workaround I did the following:

In http.cs I changed the AppendCookies method such that in the foreach loop it did the following:

/*var cookie = new Cookie
{
Name = httpCookie.Name,
Value = httpCookie.Value,
Domain = webRequest.RequestUri.Host
};*/ //Commented out
                var cookie = new Cookie(httpCookie.Name, httpCookie.Value, "/"); //Replaced above

Using the constructor of Cookie seemed to make all the difference for me. 

As I say, I haven't investigated further, as this worked for me. I will get around to raising an issue and doing a proper fix.

I hope this helps.

Kind Regards
Chris

Espen H.

unread,
Jul 4, 2011, 2:43:40 PM7/4/11
to RestSharp
I tried your solution: downloaded the source, added that as a
reference instead of the dll and changed http.cs as you noted above.
Now it works like a charm.
Reply all
Reply to author
Forward
0 new messages