Allow CookieContainer to be Serialized/Deserialized
Currently, serialization and deserialization of the CookieContainer doesn't work. The documentation says to use the CookieContainer if one needs to save off HttpOnly cookies. It seems that saving the CookieContainer isn't possible.
"If the server sends HTTPOnly cookies, you should create a System.Net.CookieContainer on the request to hold the cookies, although you will not see or be able to access the cookies that are stored in the container."
While I understand the limitation for the web version of Silverlight (somewhat) this is just pure annoyance on the phone. Hiding HttpOnly cookies makes it impossible to validate that authentication happened successfully in some forms-based authentication scenarios since the cookie count may show 0 cookies returned, even though they were.
Eric StJohn commented
This should be combined with https://wpdev.uservoice.com/forums/110705-dev-platform/suggestions/2278081-allow-cookiecontainer-to-be-serialized-deserialize. They are essentially the same issue. This is a place where Phone is inconsistent with Desktop and Windows Store. It would be great to see this fixed so that the platforms converge.
Ilija Injac commented
Yeah, it's really about time. This is frustrating and very annoying. Would be great to have such a feature!
need to know how to persist the CookieContainer !!
Did you try re-using Response.Cookies for subsequent calls? (by adding it to Request.CoockieCollection)? If you inspect the response cookie, it may not show few cookies, but those cookies are indeed parsed by the framework object, and contained in the Cookies collection. You just need to add it back to subsequent requests.
I agree with you, having an ability to access all of the cookies via code makes our life easier.
Not being able to restore a CookieContainer means re-authenticating after being tomstoned.