从我的 Blazor 服务器 Azure 托管应用程序向 http: 服务器发出请求会导致超时。
请求 https:服务器工作。
来自浏览器的请求如果发送到 http 资源则有效,如果从 https 发送则失败(被阻止)。
我如何理解我的应用程序中存在相同的混合内容问题。 我该如何绕过这个?可以吗?
我需要发送请求的API服务器不接受https。
非常感谢!
public static async Task<HttpResponseMessage> GetVersion()
{
var client = new HttpClient
{
BaseAddress = new Uri("http://webservice....")
};
var getVersion = new Version();
HttpResponseMessage response = await client.PostAsJsonAsync("", getVersion);
response.EnsureSuccessStatusCode();
return response;
}
在互联网上搜索让人感觉这是不可能的。
看起来这不是混合内容问题。 奇怪的是,使用 PostAsync 方法而不是 os PostAsJsonAsync 对其进行了排序。 以下工作没有任何问题。
using System.Text;
public static async Task<string> GetVersion()
{
var client = new HttpClient();
var getVersion = new Version();
string json = "{\""+"getVersion"+"\": {}}";
var requestData = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
"http://webservice....", requestData);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}