Bug 11307 - BasicHttpBinding.AllowCookies does not work
Summary: BasicHttpBinding.AllowCookies does not work
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies ()
Version: 2.10.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
: 21889 ()
Depends on:
Reported: 2013-03-20 18:08 UTC by Bryan Moulton
Modified: 2014-08-29 12:41 UTC (History)
9 users (show)

Is this bug a regression?: ---
Last known good build:

Test case (69.91 KB, application/zip)
2014-06-18 19:44 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Proposed patch (869 bytes, patch)
2014-06-18 19:52 UTC, Brendan Zagaeski (Xamarin Team, assistant)

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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 GitHub or Developer Community 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.

Related Links:

Description Bryan Moulton 2013-03-20 18:08:38 UTC
In reference to case #29385

In Mono 2.10.12, the BasicHttpBinding property no longer supports EnableHttpCookieContainer because it is Depreciated. The replacement is AllowCookies, but this property does not work. Upon inspection of the source code the following line is found:

The HttpCookieContainerBindingElement is added in accordance with EnableHttpCookieContainer, but not AllowCookies.
Comment 1 Jeroen 2013-04-11 08:56:22 UTC
Same problem here, I just updated Xamarin with the stable release and it still contains this bug. The company I work for can't go on with it like this...
Comment 2 Jonas Sourlier 2013-08-15 03:21:00 UTC
Same problem here, using Xamarin.iOS with iOS 7.
Comment 3 Yuri 2013-11-15 14:43:21 UTC
Is there any plans to fix this?
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-18 19:44:20 UTC
Created attachment 7110 [details]
Test case

Here's an example WCF service + client that uses cookies. This test case *succeeds* on desktop Mono and .NET, but fails on Xamarin.Android and Xamarin.iOS.

## Steps to reproduce

1. Follow the steps on [1] to set up and run the "WcfService1" solution from the attached test case in IISExpress.

[1] http://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/walkthrough_working_with_WCF/#Configuring_Remote_Access_to_IIS_Express

2. Once "WcfService1" is running, open the "Clients" solution.

3. Set either the Android or iOS project as the startup project.

4. Change the IP address and port in the call to `new Service1Client()` to match the address and port you set up for "WcfService1" in step 1.

5. Run the Android or iOS project (on simulator or device).

6. Tap the "Send Cookies" button, and wait for the text view to display "Sent cookies."

7. Tap the "Read Cookies" button.

## Result

The text view will display:
"Server sent back cookie: Key=NA, Value=NA"

## Expected result

The text view should display the same result as the "Console" test app (on Mono 3.4.0 or .NET):
"Server sent back cookie: Key=Company, Value=Xamarin"

## Version Information

### Mac
Xamarin.Android 4.12.5
Mono 3.4.0

### Windows
Xamarin 3.1.198
.NET 4.5.51641
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-18 19:52:45 UTC
Created attachment 7112 [details]
Proposed patch

Here's a patch that allows the test case from comment 4 to run successfully on both Xamarin.iOS and Xamarin.Android.

Based on this result, it seems that the conditional compile logic at [1] is no longer needed for Xamarin.iOS or Xamarin.Android.

[1] https://github.com/mono/mono/blob/97d52b223/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelFactory.cs#L55-L63
Comment 6 Miguel de Icaza [MSFT] 2014-06-19 17:45:29 UTC
Thanks for the patch, applied!
Comment 7 Yuri 2014-08-03 14:10:35 UTC
Did it make to the last release? I don't see setting AllowCookies in my code fixes the problem.
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2014-08-29 12:17:03 UTC
The test case from comment 4 works correctly as of the current beta versions:

Xamarin.Android 4.16.0
Xamarin 3.5.55

These versions will be moving to the stable channel soon.

The current stable versions do _not_ include the patch:
Xamarin.Android 4.14
Xamarin 3.3.47
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2014-08-29 12:41:16 UTC
*** Bug 21889 has been marked as a duplicate of this bug. ***