【发布时间】:2015-12-18 23:39:47
【问题描述】:
我想为一个使用 Domoticz 的 domotic 项目创建自己的远程应用程序,并在 C# 中使用 Universal Apps (Win 10)。 我使用 Basic-Auth,它与 WinForm 或 WPF 项目完美配合,我可以连接并获取(在这种情况下)或在服务器中设置值:
private async void request()
{
string uri = @"http://username:password@192.168.1.1:8080/json.htm?type=devices&filter=all&used=true&order=Name";
HttpClient client = new HttpClient();
string token = Convert.ToBase64String(Encoding.ASCII.GetBytes("username:password"));
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", token);
string body = await client.GetStringAsync(uri);
}
但是,此示例不适用于通用应用程序(Win 10),我收到此异常:
An error occurred while sending the request.
当我查看 InnerException 时,我发现:
A security problem occurred. (Exception from HRESULT: 0x800C000E)
是否有解决方案可以将我的应用程序连接到我的家庭服务器,例如 WinForms 应用程序?
【问题讨论】:
标签: c# http-headers httprequest win-universal-app