【问题标题】:how create get url from Visual Studio 2015 for Windows Iot in app C#如何在应用程序 C# 中从 Visual Studio 2015 for Windows Iot 创建获取 url
【发布时间】:2016-01-19 13:40:33
【问题描述】:

如何在应用程序 C#(通用应用程序 Windows)中从 Visual Studio 2015 for Windows Iot 创建获取 url

c# 2015 中的Getreponse(); 已弃用

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://XXX/online?check=useronline");
request.Method = "GET";
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
using (var reader = new StreamReader(stream))

【问题讨论】:

  • 你在找什么网址?
  • 从网站“myurl.com/online?check=useronline”获取玩家连接输出 200 只有文本没有 html。
  • 请尽量具体说明您的问题。我们无法猜测您的应用程序是关于什么的……例如:播放器如何连接到您的服务器以及到目前为止您尝试了什么。
  • 好的,我的帖子更新了

标签: c# http-get iot windows-10-iot-core windowsiot


【解决方案1】:

Universal App Platform 有一个很棒的 HTTP 类。

只需几行代码,HttpClient 就可以满足您获取 Web 资源所需的一切。

var client = new HttpClient();
var content = await client.GetStringAsync(new Uri("http://danvy.tv"));

在这里查看详细信息

https://msdn.microsoft.com/en-US/library/windows/apps/xaml/windows.web.http.httpclient.getstringasync

【讨论】:

    【解决方案2】:

    你可以看看这个例子。

    https://ms-iot.github.io/content/en-US/win10/samples/BlinkyWebServer.htm

    从一个函数接收的所有请求都可以轻松使用 reqex 并创建您的网络服务。

    【讨论】:

      猜你喜欢
      • 2016-12-11
      • 1970-01-01
      • 1970-01-01
      • 2016-05-19
      • 1970-01-01
      • 2013-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多