Bug 25701 - WebRequest Fails with HttpRequestHeader.IfModifiedSince
Summary: WebRequest Fails with HttpRequestHeader.IfModifiedSince
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.18.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2015-01-04 12:26 UTC by Cody Beyer (MSFT)
Modified: 2017-07-05 17:44 UTC (History)
6 users (show)

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

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 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.

Related Links:
Status:
RESOLVED NORESPONSE

Description Cody Beyer (MSFT) 2015-01-04 12:26:26 UTC
### Description

Using HttpRequestHeader.IfModifiedSince causes an exception when ran within Android/iOS. The same exception does not occur if using Windows Phone.

### Test Case

https://dl.dropboxusercontent.com/u/107030794/WebRequest.zip

### Steps to Reproduce

1. Download Test Case
2. Open in XS/VS
3. Run on Xamarin Android Player

### Expected Results

Http Request completes without error

### Actual Results

Exception occurs

### Stack Trace

>System.ArgumentException: This header must be modified with the appropiate property.
>  at at System.Net.WebHeaderCollection.CheckRestrictedHeader (string) <IL 0x00040, 0x00117>
>  at at System.Net.WebHeaderCollection.Set (string,string) <IL 0x00059, 0x00183>
>  at at System.Net.WebHeaderCollection.Set (System.Net.HttpRequestHeader,string) <IL 0x00009, 0x0004c>
>  at at System.Net.WebHeaderCollection.set_Item (System.Net.HttpRequestHeader,string) <IL 0x00003, 0x0002f>
>  at WebRequest.WebReqestPage.OnAppearing (object,System.EventArgs) [0x0004b] in /Users/codybeyer/Downloads/WebRequest/WebRequest/WebRequest/WebReqestPage.xaml.cs:30
>  at at Xamarin.Forms.Page.SendAppearing () <IL 0x00032, 0x000c8>
>  at at Xamarin.Forms.Platform.Android.PageRenderer.OnAttachedToWindow () <IL 0x00011, 0x0006f>
>  at Android.Views.View.n_OnAttachedToWindow (intptr,intptr) [0x00009] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:12397
>  at at (wrapper dynamic-method) object.831fb02e-72ed-4c64-b643-7b606dd63d68 (intptr,intptr) <IL 0x00011, 0x0001b>

### Version(s)

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Windows Phone 8.1 SDK Integration 1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0 1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin 3.8.150.0 (10cfd178d55287f09c85f5a1e604dfe20889a40f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android 4.20.0.28 (ba9bbbdd44cfdc4bf485e8885bd2ad24fba525f7)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 8.4.0.0 (840a925103a0bf4a856507f13d5eaee3c1579c2f)
Visual Studio extension to enable development for Xamarin.iOS.




=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: 3e4348fa-e0b3-46a4-8426-58f27e19159e
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: 8.6.0.41 (Business Edition)
Hash: 2c57f4e
Branch: 
Build date: 2014-12-18 16:42:49-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-18 00:38:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40

=== Operating System ===

Mac OS X 10.10.1
Darwin Codys-MacBook-Pro.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 1 Arpit Jha 2015-01-05 02:50:55 UTC
I have checked this issue  and able to reproduce with the help of bug description and attached sample and getting same behaviour.

Note: Application getting crashed on android as well as iOS device.

Screencast:  http://www.screencast.com/t/zwnAfQzM
XAP device logs :  https://gist.github.com/Arpit360/6b27c6c0ecdaa11768b5
Application output : https://gist.github.com/Arpit360/43e9f8d744886b17b66f

Environment :

=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: 3d25a767-a003-4a7d-9f5e-e57987cf6cf0
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6602)
Build 6A1052c

=== Xamarin.iOS ===

Version: 8.6.0.45 (Enterprise Edition)
Hash: 0376f62
Branch: 
Build date: 2014-12-23 17:34:21-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Enterprise Edition)
Android SDK: /Users/mac360_xamarin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Enterprise Edition)

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-18 00:38:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40

=== Operating System ===

Mac OS X 10.10.0
Darwin mac360-xamarins-Mac-mini.local 14.0.0 Darwin Kernel Version 14.0.0
    Fr
Comment 2 Andrey Butcitcyn 2015-03-12 07:25:42 UTC
The same behavior for UserAgent header.
Comment 3 nmilcoff 2016-02-09 14:34:39 UTC
I was having this problem but I've been able to sort it out by adding Microsoft.Net.Http package in my Xamarin.iOS & Xamarin.Android projects.
Comment 4 Marek Habersack 2016-08-30 21:42:29 UTC
The sample provided in comment 0 is no longer accessible, please attach a new one and reopen the bug, thanks!
Comment 5 Chris Hardy [MSFT] 2017-07-05 17:44:44 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!