Xamarin.forms: [WPF] Xamarin.Forms WPF load local html throw ArgumentException with message "Relative URIs are not allowed"

Created on 12 Feb 2018  路  5Comments  路  Source: xamarin/Xamarin.Forms

Description

Load local html with the following code will throw ArgumentException with message "Relative URIs are not allowed":

var source = new HtmlWebViewSource()
{
    BaseUrl = "https://www.google.com/",
     Html = @"<html><body> <h1>Xamarin.Forms</h1> <p>Welcome to WebView.</p> </body>
   </html>"
};
WebView.Source = source;

Steps to Reproduce

  1. Create Xamarin.Forms project
  2. Follow instruction how to create Xamarin.Forms WPF
  3. Add WebView control and use above code

Expected Behavior

Show web page

Actual Behavior

throw ArgumentException with message "Relative URIs are not allowed"

Basic Information

  • Version with issue: 3.0.0-ci0011
  • IDE: VIsual Studio 2017 15.5.3
  • Platform Target Frameworks: WPF
WPF bug

All 5 comments

I am still confuse, what xamarin.forms version should I use to test prelease, is it 3.0.x or 2.6.x? I see that xf 3.0.x has Xamarin.Forms.Platform.WPF merged to it and 2.6.x hasn't

For now my solution was to create my own WebView renderer and copy all WebViewRenderer, change the code from https://github.com/xamarin/Xamarin.Forms/blob/b96f65bdd9e7e931971338b122a8940e2a35ccc7/Xamarin.Forms.Platform.WPF/Renderers/WebViewRenderer.cs#L74-L77 to

Control.NavigateToString(html);

and also I put try-catch inside WebBrowserOnNavigated and WebBrowserOnNavigating

Hello,

Version 3.0.0-ci0011 is a version that was created before adding the project to Xamarin Forms main project.

It is no longer necessary to use AppVeyor but use the nigltly build of Xamarin Forms. https://blog.xamarin.com/try-the-latest-in-xamarin-forms-with-nightly-builds/

Regarding the bug, I'm going to watch this.

Thanks for your report

Ok, looking forward for this!

Was this page helpful?
0 / 5 - 0 ratings