How to convert NSHttpCookie to System.Net.Cookie in MonoTouch?

I have a MonoTouch iPhone app that does federated login through the Azure Access Control Service. Login is via the built-in UIWebView browser. When the login is done, I want to transfer the cookie to my application. I have access to

NSHttpCookieStorage.SharedStorage.Cookies 

so i can find the cookie. But in order to call back end services, I need to have

 System.Net.Cookie 

which I can put in a CookieContainer to send to the service.

How do I convert between two ... is this the only way?

 NSHttpCookie cookie = NSHttpCookieStorage.SharedStorage.Cookies[0]; System.Net.Cookie newCookie = new System.Net.Cookie() { Name = cookie.Name, Value = cookie.Value, Version = (int) cookie.Version, Expires = cookie.ExpiresDate, Domain = cookie.Domain, Path = cookie.Path, Port = cookie.PortList[0].ToString(), // is this correct?? Secure = cookie.IsSecure, HttpOnly = cookie.IsHttpOnly }; 
+6
source share
1 answer

Yes, so you can convert. Perhaps you should just create an extension method for NSHttpCookie? Then you can call something like:

 var c = cookie.ToCLRCookie (); 
+3
source

All Articles