Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Problem with WebView

Hi. I'm creating a mobile app of existing website. I use HTMLAGILITYPACK to scrap some data from website. I want to display them in my app. But there is no result and nothing displays.

This is my App code with "scraper":

namespace Apka
    public partial class App : Application
        public static string DocumentPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        public static string strona = "";

        public static NavigationPage NavigationPage { get; private set; }
        WebRequest request = HttpWebRequest.Create("");
        WebResponse response;

        public App()



            NavigationPage = new NavigationPage(new MainPage());
            RootPage rootPage = new RootPage();
            MenuPage menuPage = new MenuPage(rootPage.vm);

            rootPage.Master = menuPage;
            rootPage.Detail = NavigationPage;
            MainPage = rootPage;


        private async void starthttp()

            response = await Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null);

            var html = new HtmlDocument();
            var nodes = html.DocumentNode.Descendants("img")
                .Where(node => node.GetAttributeValue("class", "")

            foreach (var node in nodes)

                strona = strona + node.OuterHtml;




In console it returns some img like blablabla

Here is my page where im trying to place scraped pictures:

namespace Apka.View.Pages
    public partial class MainPage : ContentPage

        public MainPage()

            WebView webView = new WebView
                Source = new HtmlWebViewSource
                    Html = @"<!DOCTYPE html><html><head><style>img { width:100%; }</style></head><body>" + App.strona + @"</body></html>",
                VerticalOptions = LayoutOptions.FillAndExpand


            /* ViewModel.Pages.MainPageViewModel vm = new ViewModel.Pages.MainPageViewModel();
             this.BindingContext = vm;*/


And XAML code to this page looks like that:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="" (cant place links)
             xmlns:x="" (here too)

        <ToolbarItem Command="{Binding MenuItem1Command}" />

        <StackLayout BackgroundColor="#505050" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">



Why webview doesn't work? What should I do to display these pictures?


  • CzebokCzebok Member

    There should be html code for picture bracket img src-"link" class="imageitself" alt="blablabla" bracket

    instead of that

    In console it returns some img like blablabla

  • DobiDobi Member

    help him noobs

  • TiagoRodriguesNesTiagoRodriguesNes USMember ✭✭

    have you tried using HTTPClient ?

    var uri = new Uri("");
    HttpClient client = new HttpClient();
    var response = await client.GetAsync(uri);
    if (response.IsSuccessStatusCode)
        var content = await response.Content.ReadAsStringAsync();
        // ... deal with data received ...
Sign In or Register to comment.