WebClient doesn't work

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
codedev
Posts: 1
Joined: Tue Aug 15, 2017 3:31 am

WebClient doesn't work

Postby codedev » Tue Aug 15, 2017 4:34 am

WebClient, loads the string and textblock shows only in the simulator, but not in the browser and on the server.

What possibly is wrong? thanks.

XAML:

Code: Select all

<Page
    x:Class="MyApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid>
        <StackPanel>
            <TextBlock x:Name="textBlock" HorizontalAlignment="Center"/>
            <Button Click="LoadButton_Click" HorizontalAlignment="Center" Content="Load"/>
        </StackPanel>
    </Grid>
</Page>




C#

Code: Select all

        private async void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            var webClient = new WebClient();
            webClient.Encoding = Encoding.UTF8;
            textBlock.Text = "loading";
            string response = await webClient.DownloadStringTaskAsync("http://www.google.com");

            textBlock.Text = response;
        }

Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 1 guest