目前我正在尝试模拟我的 Android 应用程序。开发的应用程序使用 xamarin.forms,可在 Android 和 iOS 上运行。
我的问题是使用httpClient 进行restful 请求时。目前我正在使用本地主机。在 iOS 上运行时没有任何问题,但是 Android 返回以下异常:
这是导致问题的代码:
var request = new HttpRequestMessage(HttpMethod.Post, sharedURL.baseUrl + "connect/token");
request.Content = new FormUrlEncodedContent(new Dictionary<string, string>
{
["grant_type"] = "password",
["username"] = username,
["password"] = password,
["scope"] = "offline_access"
});
var response = await client.SendAsync(request, HttpCompletionOption.ResponseContentRead);
我相信这可能与 https 有关,因为我的 Restfull 服务不是使用 https 设置的。但是我无法在 Android 上禁用此功能。有什么线索吗?
最佳答案
关于c# - Http.HttpRequestException Xamarin.forms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44177530/