Consider a web response with this header:
Set-Cookie: sample=testCookie; Domain=.sample.com; Expires=Tue, 25-Jan-2012 00:49:29 GMT; Path=/
this header would be mapped to CookieCollection
in .NET
. And also when we deal with a CookieCollection
it will finally converted to such a header string
.
I'm looking some way to purely do this conversions in two way. Surely .NET
has it in it's internal library. I believe any class which constructs object model from text and vice versa should support two methods (here CookieCollection
):
// Creating cookie collection from header text
CookieCollection.TryParse(cookieHeaderString, out myCookieCollection);
// and getting the final header which would be sent by request
String cookieHeaderString = myCookieCollection.GetCookieHeaderString();
How can I achieve that with CookieCollection
?