用PostMan调试ASP.NET Core Web Api https接口时,遇到Could not get any response怎么办
现在新建Asp.Net Core站点时,已默认启用https,当点击运行时,就会跳转至 https://localhost:5001 , 在我们使用postman调试接口时,可能会遇到 Could not get any response
错误,解决方案有两个。
项目不启用https
因为祸起https,首先想到的就是关闭https,继续使用http进行调试,这里有两种关闭方法,任选其一。
找到launchSettings.json文件,移除掉https相关网址。
在 startup.cs 里注释掉
UseHttpsRedirection
,同时在 lanuchsettings.json 里找到 applicationUrl,将http网址移至最前边,当然删除https网址也可以。
"applicationUrl":"http://localhost:5000;https://localhost:5001"
修改postman设置
在 File > Settings > SSL certificate verification,将on改为off。
个人比较推荐第二种方案。