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.
I am trying to load a local web page on Xamarin Forms using WebView.
The specific web page is trying to access server data using jQuery.
I am getting the following error (running on an Android device):
[chromium] [INFO:CONSOLE(0)] "XMLHttpRequest cannot load https://XXX. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.", source: file:///android_asset/ (0)
Shouldn't WebView allow such queries?
On iOS everything works fine.
=== Xamarin Studio Business ===
Version 6.2 (build 1821)
Installation UUID: 07360e74-2c80-443b-94a1-6221c776bc97
Mono 4.8.0 (mono-4.8.0-branch/e4a3cf3) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 408000495
=== NuGet ===
=== Xamarin.Profiler ===
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Apple Developer Tools ===
Xcode 8.2.1 (11766.1)
=== Xamarin.iOS ===
Version: 10.4.0.123 (Xamarin Business)
Build date: 2017-02-16 17:40:00-0500
=== Xamarin.Mac ===
Version: 184.108.40.2063 (Xamarin Business)
=== Xamarin Inspector ===
Build date: Wed, 22 Feb 2017 23:24:11 GMT
=== Xamarin.Android ===
Version: 220.127.116.11 (Xamarin Business)
Android SDK: /Users/shayo/Library/Android/sdk
Supported Android versions:
4.0.3 (API level 15)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.1
Java SDK: /usr
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
Android Designer EPL code available here:
=== Xamarin Android Player ===
Location: /Applications/Xamarin Android Player.app
=== 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.2
Darwin Shays-MacBook-Pro.local 16.3.0 Darwin Kernel Version 16.3.0
Thu Nov 17 20:23:58 PST 2016
Thank you for filing this report! You might be able to resolve this by using a custom WebView renderer to set setAllowUniversalAccessFromFileURLs to true. Let me know if this helps!
Can you please post a full solution?
I haven't tested this with a full app, but you can try a custom renderer like this: https://gist.github.com/jimmgarrido/b3a1bd8fc130435b53f62cb5736368a9
Thanks Jimmy. It works. You can close this ticket. Please consider adding this as the default behavior (seems like this is the case for WebView in iOS).
Minor comment. This only works if the server adds to the page the header
Is there a way to fix this for pages that I am not hosting?
Glad to hear it is working now! Regarding the header question, unfortunately that does not appear to be possible unless you have access to the server: https://www.html5rocks.com/en/tutorials/cors/