Page 1 of 1

If the method which includes "await wc.DownloadStringTaskAsync (url)", then the method name can not be Chinese, otherwis

Posted: Wed Dec 07, 2016 4:32 pm
by tomny
Dear JS-Support,

If the method which includes "await wc.DownloadStringTaskAsync (url)", then the method name can not be Chinese, otherwise ...

The following code works fine in the emulator and the browser:

Code: Select all

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using System.Net;

namespace GetTest1
{
    public partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            this.Loaded += MainPage_Loaded;         
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            get();
        }

        public async void get()
        {
            WebClient wc = new WebClient();
            wc.Encoding = System.Text.Encoding.UTF8;
            string url = "http://localhost:30095/GetMoBanList.aspx";
            string mbStr = await wc.DownloadStringTaskAsync(url);
            System.Windows.MessageBox.Show(mbStr);
        }
    }
}

The above code works as shown below
Image070.png
Image070.png (34.12 KiB) Viewed 4240 times


Then we make the following changes to the code, "get()" to "获取()" (that is, the method name to Chinese):

Code: Select all

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using System.Net;

namespace GetTest1
{
    public partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            this.Loaded += MainPage_Loaded;         
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            获取();
        }

        public async void 获取()
        {
            WebClient wc = new WebClient();
            wc.Encoding = System.Text.Encoding.UTF8;
            string url = "http://localhost:30095/GetMoBanList.aspx";
            string mbStr = await wc.DownloadStringTaskAsync(url);
            System.Windows.MessageBox.Show(mbStr);
        }
    }
}


Modified, it can work in the simulator, and in the browser, the following tips will not work:
Image071.png
Image071.png (21.4 KiB) Viewed 4240 times

Image072.png
Image072.png (69.98 KiB) Viewed 4240 times


Best Regards,
Tomny

Re: If the method which includes "await wc.DownloadStringTaskAsync (url)", then the method name can not be Chinese, othe

Posted: Wed Dec 07, 2016 4:53 pm
by tomny
Coupled with the last time I found the situation: binding attribute name can not be Chinese,

viewtopic.php?f=5&t=7872

So, in the case of the browser running, if the program contains Chinese, it will appear a variety of problems, for example, the method name can not be Chinese I need to test many times to determine this problem. There is also a confusion is that it is normal in the simulator in the browser before the problem, so that once the problem is difficult to determine where the problem lies.

I now know that I write code in the process should try to avoid the use of the Chinese, if this is a cshtml5 start with a new project, then I will certainly do so, the problem is that some of my previous silverlight project, if the code re-modified The workload is relatively large, and not conducive to code-sharing.

Thanks,
Best Regards,
Tomny