Dưới đây mã hoạt động tốt trên localhost nhưng Bắt lỗi ở trên sau khi triển khai api của tôi trên Azure.Azure api Yêu cầu bị hủy: Không thể tạo kênh bảo mật SSL/TLS. http khách hàng Trong khi gọi một số trang web api
Mã của tôi là như sau:
public class UsersController : Controller
{
private readonly HttpClient _client;
public UsersController()
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
_client = new HttpClient { BaseAddress = new Uri("https://pincode.saratchandra.in/api") };
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public JsonResult GetAddress(int pincode)
{
var response =_client.GetAsync("/pincode/125112").Result;
//Here it throws an exception: got no response
if (response.IsSuccessStatusCode)
{
}
return Json(ApiResult.Success(), JsonRequestBehavior.AllowGet);
}
đã không nhận được bất kỳ phản ứng đối với cuộc gọi trên chỉ nhận được lỗi
Yêu cầu đã bị hủy bỏ: Không thể tạo SSL/TLS secure channel
bạn đã tìm thấy một sửa chữa cho điều này? Trải nghiệm cùng một vấn đề. –
Không, tôi không thể tìm được bản sửa lỗi cho nó. – jitender
Bạn có đang sử dụng Dịch vụ ứng dụng Azure hoặc Dịch vụ đám mây Azure cho API của mình không? – TwistedStem