Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
When creating a new cookie with the code below, goodCookie works, but badCookie fails:
var props = new NSMutableDictionary();
props.Add(new NSString("OriginURL"), new NSString("yodawg.com"));
props.Add(new NSString("Name"), new NSString("iherd"));
props.Add(new NSString("Value"), new NSString("ulikecookies"));
var goodCookie = new NSHttpCookie(props);
var badCookie = NSHttpCookie.CookieFromProperties(props);
Also, can we *PLEASE* get these constants defined so users don't have to guess at the proper property key values:
Both your cookies are bad. Objective-C selectors for them both returns null. However when we map a selector to a .NET constructor we can't return null - so an empty instance is returned (i.e. it's handle is 0x0).
This code will work:
var props = new NSMutableDictionary ();
props.Add (NSHttpCookie.KeyOriginURL, new NSString("http://yodawg.com"));
props.Add (NSHttpCookie.KeyName, new NSString("iherd"));
props.Add (NSHttpCookie.KeyValue, new NSString("ulikecookies"));
props.Add (NSHttpCookie.KeyPath, new NSString("/"));
The differences are:
* it provides an URL scheme, http://, to the origin URL;
* it provides a Path (mandatory);
* it uses the (already defined) constants (but it would work with manually created keys)
It still a pretty ugly API to use (outside Objective-C ;-) so I'll add a some .NET constructors, that will help people write beautiful code, before closing the bug report.
Verified new Constructor exists and creates cookie with data provided.