Bug 52844 - WebRequest.CreateHttp can't recognize a valid URL or URI
Summary: WebRequest.CreateHttp can't recognize a valid URL or URI
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 5.0.0 (2017-02)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2017-02-27 16:07 UTC by Glauber
Modified: 2017-10-06 21:54 UTC (History)
4 users (show)

See Also:
Tags: Cycle9R
Is this bug a regression?: ---
Last known good build:

Exception Message (105.32 KB, image/png)
2017-02-27 16:07 UTC, Glauber
Url used (11.07 KB, image/png)
2017-02-27 16:07 UTC, Glauber
Sample Project, with the code I'm using right now (3.99 MB, application/zip)
2017-02-28 17:24 UTC, Glauber

Description Glauber 2017-02-27 16:07:28 UTC
Created attachment 20004 [details]
Exception Message

After update to Mono SDK 4.8 the application throws an exception when try to create WebRequest.CreateHttp("http://www.microsoft.com"), says that's an invalid prefix, the same code runs fine on mono 4.6.x

The framework throws an exception even when used like this:

var url = new Uri("http://www.microsoft.com");
var request = WebRequest.CreateHttp(url);

With the same error, invalid prefix.
Comment 1 Glauber 2017-02-27 16:07:55 UTC
Created attachment 20006 [details]
Url used
Comment 2 Marek Safar 2017-02-28 14:47:13 UTC
Could you attach your project? Simple sample like

using System;
using System.Net;

namespace consoletest4
	class MainClass
		public static void Main (string [] args)
			var url = new Uri ("http://www.microsoft.com");
			var request = WebRequest.CreateHttp (url);			

works as expected (no error)
Comment 3 Glauber 2017-02-28 17:24:12 UTC
Created attachment 20034 [details]
Sample Project, with the code I'm using right now
Comment 4 Glauber 2017-02-28 17:27:14 UTC
Hi Marek, 

Just added a sample code, on my machine the error still occurs, maybe there's a conflict on my machine (I've installed and then uninstalled the beta version with Visual Studio for Mac), is it possible?
Comment 6 Jon Goldberger [MSFT] 2017-03-01 22:19:36 UTC
Non-engineering team preliminary quick review
(See https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/howto-file-bug/ for general reference.)

## Focuses on one problem?

## Suspected to be a regression or a problem with a new feature?
Yes, according to the bug reporter, but I could not reproduce this issue with Mono 4.8 using either Xamarin Studio or Visual Studio for mac. 

## Specific to one particular project, development computer, or target mobile device?
Uncertain. The issue is described as occurring in a template project with minimal code, but the issue might be specific to a particular development environment since I as not able to reproduce it directly in my brief initial attempt.

## Includes clear steps to reproduce the problem?
No, though a sample project was provided, I could not reproduce on my system with the sample provided.

## Considers the relevant log files for the part(s) of the process where something goes wrong (IDE editing, MSBuild building, deploying, launching, attaching the debugger, an in-app error, or something else), and has them attached?
A runtime exception message was provided. 

## Already took up time for many users?
Not yet. The reporter is so far the only user on CC on this bug report, and I didn't notice any other recent reports that looked like a match. But since I can not reproduce the issue, I have no way at this time of gauging the impact.  

To Glauber:

Can you provide your full version info for the IDE you are using (Xamarin Studio or Visual Studio for Mac) so we can try to match your environment exactly? 

Version Information
In Xamarin Studio/Visual Studio (Mac), version information can be obtained by navigating to: Xamarin Studio (or Visual Studio) -> About Xamarin Studio  (or Visual Studio) -> Show Details -> Copy Information button.
Comment 7 Glauber 2017-03-06 12:52:32 UTC
=== Xamarin Studio Community ===

Version 6.2 (build 1821)
Installation UUID: c0b56966-a948-4183-8472-b1ef3be2c4a7
	Mono 4.8.0 (mono-4.8.0-branch/e4a3cf3) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000495

=== NuGet ===


=== Xamarin.Profiler ===

Version: 1.2.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: (Xamarin Studio Community)
Android SDK: /Users/glauberbrandao/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		6.0   (API level 23)

SDK Tools Version: 25.1.2
SDK Platform Tools Version: 24.0.0
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:

=== Xamarin Android Player ===

Not Installed

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin Inspector ===

Hash: cdc01b9
Branch: 1.1-release
Build date: Wed, 22 Feb 2017 23:24:11 GMT

=== Xamarin.iOS ===

Version: (Xamarin Studio Community)
Hash: 35d1ccd
Branch: cycle9
Build date: 2017-02-16 17:40:00-0500

=== Xamarin.Mac ===

Version: (Xamarin Studio Community)

=== Build Information ===

Release ID: 602001821
Git revision: d41b6e51f3fa46a1943f2e31a778d28a7c73d069
Build date: 2017-02-17 15:18:19-05
Xamarin addins: 1363a8d943bab7700c93a97474060b6734aa7f94
Build lane: monodevelop-lion-cycle9

=== Operating System ===

Mac OS X 10.12.3
Darwin Maqui-Pro.local 16.4.0 Darwin Kernel Version 16.4.0
    Thu Dec 22 22:53:21 PST 2016
    root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

DNX 0.6

Also here is a video showing the exception: https://www.screencast.com/t/HPfSMLC6Kt
Comment 8 Glauber 2017-05-10 22:34:06 UTC

The error still happening with the latest version of mono.

	"ClassName": "System.NotSupportedException",
	"Message": "The URI prefix is not recognized.",
	"Data": null,
	"InnerException": null,
	"HelpURL": null,
	"StackTraceString": "  at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x000a4] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/WebRequest.cs:207 \n  at System.Net.WebRequest.CreateDefault (System.Uri requestUri) [0x00014] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/WebRequest.cs:304 \n  at System.Net.WebRequest.CreateHttp (System.Uri requestUri) [0x00048] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/WebRequest.cs:323 \n  at Aleyant.Pressero.Tools.AWI.Communication.Rest.PresseroRestAPI.CallApi[T] (System.String path, System.Object payload, System.Boolean authenticate, Aleyant.Pressero.Tools.AWI.Entities.HttpVerb verb) [0x00035] in ",
	"RemoteStackTraceString": null,
	"RemoteStackIndex": 0,
	"ExceptionMethod": null,
	"HResult": -2146233067,
	"Source": "System"

Tested the code on two machines and the error still occurs.
Comment 9 Glauber 2017-05-10 22:37:10 UTC
Visual Studio Community 2017 for Mac
Version 7.0 (build 3146)
Installation UUID: 1728c7d8-3e88-487c-9cb8-d7ebfb87423f
	Mono (2017-02/9667aa6) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 500000100


.NET Core
Runtime: /usr/local/share/dotnet/dotnet
SDK: /usr/local/share/dotnet/sdk/1.0.3/Sdks
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.0.0/lib/mono/msbuild/15.0/bin/Sdks

Version: 1.5.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Apple Developer Tools
Xcode 8.3.2 (12175)
Build 8E2002

Version: (Visual Studio Community)

Not Installed

Xamarin Inspector
Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

Xamarin.iOS not installed.
Can't find mtouch or the Version file at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current.

Build Information
Release ID: 700003146
Git revision: 7553fda2e327d15807298d444007896e5b975dba
Build date: 2017-05-09 12:12:36-04
Xamarin addins: c3d580752be79fc902422f1d55d1cdc2d8b98799
Build lane: monodevelop-lion-d15-2

Operating System
Mac OS X 10.12.4
Darwin 16.5.0 Darwin Kernel Version 16.5.0
    Fri Mar  3 16:52:33 PST 2017
    root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Comment 10 Marek Safar 2017-10-06 21:54:26 UTC
I can no longer reproduce it with Mono 5.4

Note You need to log in before you can comment on or make changes to this bug.