带有 HTTPS 的 WCF Web Api
只是为了提供一些背景信息。 ASP.NET MVC2 网络应用程序接口5 IIS 7
我尝试使用 WCF Web API,一旦启用 HTTPS,它就会停止工作。
我注意到的事情: 我通过 jquery 进行 API 调用,并且我有类似这样的 url: http://www.domain.com/api/serviceApi/SetForeignToken?token=ASDAS-ASDAS-ASDASD-ASDASDAS&foreignToken=AS123ASD
当我使用 API 测试 UI 时,我通过: https://www.domain.com/api/serviceApi/Test 我看到测试网址: https://devserver.ad.domain.com/api/serviceapi/SetForeignToken?token=ASDAS-ASDAS-ASDASD-ASDASDAS&foreignToken=AS123ASD 看起来很奇怪,它将 DNS 解析为计算机名称,而不是像以前没有 HTTPS 时那样保留正常的 DNS。
有谁知道如何配置API以使其在HTTPS下工作,或者甚至可能吗?
谢谢,
附言。开发环境有一个自签名证书,而生产环境将有一个真实的证书。
Just to put some context.
ASP.NET MVC2
Web API 5
IIS 7
I am trying to use the WCF Web API and as soon as I enable HTTPS, it stop working.
Things I noticed:
My API call I do through jquery, and I have something like this as the url:
http://www.domain.com/api/serviceApi/SetForeignToken?token=ASDAS-ASDAS-ASDASD-ASDASDAS&foreignToken=AS123ASD
When I use the API test UI I through:
https://www.domain.com/api/serviceApi/Test
I see for the test url:
https://devserver.ad.domain.com/api/serviceapi/SetForeignToken?token=ASDAS-ASDAS-ASDASD-ASDASDAS&foreignToken=AS123ASD
It just seems od the it resolves the DNS to the machine name instead of keeping the normal DNS, as it did before without HTTPS.
Does anyone know how to configure the API to make this work unde HTTPS, or is it even possible?
Thanks,
PS. The Development Enviroment has a self-signed certificate while the production will have a real certificate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,WCF Web API 支持 HTTPS。我相信有几种方法可以做到这一点(包括代码选项)。我只想在一台服务器上启用 https,因此我在 web.config 中执行了此操作:
Yes, WCF Web API supports HTTPS. I believe there are a couple of ways to do this (including a code option). I only wanted https enabled on one server so I did this in my web.config:
谢谢你们。花了一整天的时间弄清楚这个。只需在 web.config 中添加代码即可运行。
Thanks guys. spent whole day figuring out this. Just added the code in web.config and it worked.