Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何从WPF应用程序调用.ashx处理程序?_.net_Wpf_Ashx - Fatal编程技术网

.net 如何从WPF应用程序调用.ashx处理程序?

.net 如何从WPF应用程序调用.ashx处理程序?,.net,wpf,ashx,.net,Wpf,Ashx,我在服务器上有.ashx通用处理程序,我想从WPF应用程序调用它来检索一些信息,可以吗?您可以使用System.Net.WebClient类访问URL using (WebClient client = new WebClient()) { client.Headers["User-Agent"] = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0)" + " (compatible; MSIE 6.0; Windows NT

我在服务器上有.ashx通用处理程序,我想从WPF应用程序调用它来检索一些信息,可以吗?

您可以使用System.Net.WebClient类访问URL

using (WebClient client = new WebClient())
{
    client.Headers["User-Agent"] = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0)" +
    " (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";

    // Download data.
    byte[] arr = client.DownloadData("http://www.yourserver.com/"); // url for .ashx file

    // Write values.
    Console.WriteLine("--- WebClient result ---");
    Console.WriteLine(arr.Length);

}
在这里你可以找到你的名字