我正在尝试将控制器中的请求发送到另一台服务器,但是它不会返回结果……一无所有。
[Route("api/[controller]")]
[ApiController]
public class GetPriceController : ControllerBase
{
// GET api/values
[HttpGet]
public async Task<ActionResult<string>> Get()
{
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(new X509Certificate2(@"client.pfx", "password"));
var HttpCl = new HttpClient(handler);
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "https://foobar.com:777")
{
Content = new StringContent("data")
};
var response = await HttpCl.SendAsync(httpRequestMessage);
return await response.Content.ReadAsStringAsync();
}
}
在SendAsync命令之后,什么也没发生。
var response = await HttpCl.SendAsync(httpRequestMessage);