首页 > 解决方案 > 通过 https 调用在 localhost 上运行的 Owin 服务

问题描述

我有一个基于 Microsoft.Owin.Hosting 的 Web 服务,通过 https 在端口 8443 上本地运行。我已将证书绑定到它,并且能够使用 Web 服务器地址 https://localhost:8443/queryendpoint 使用 Chrome 进行连接。但是,我想使用在该机器上的客户端浏览器页面中运行的脚本来调用 Web 服务。

$.ajax({
        headers:{
            "Accept":"application/json",
            "Content-type":"application/x-www-form-urlencoded"
        },
        type: "GET",
        "rejectUnauthorized": false, 
        url:"https://localhost:8433/queryendpoint",
        success:function(response){
          var r=JSON.parse(response);
.
.
.
        }
      }); 

脚本运行时会导致错误: GET https://localhost:8433/queryendpoint net::ERR_CONNECTION_REFUSED

该错误还会返回从 Postman 调用 Web 服务器地址。

是什么导致了这个错误,我该如何解决?

标签: jqueryssl-certificateowinself-hosting

解决方案


该问题已通过指定正确的端口得到解决。:/


推荐阅读