问题描述
我通过IIS Express将VS2013设置为使用自定义域,如下所示:
I have VS2013 set up with IIS Express to use a custom domain as follows:
http://mydomain.local
https://mydomain.local
端口80 url很好用,端口443无效(错误的请求,无法显示页面,又名站点不存在).
The port 80 url works great, the port 443 does not (Bad Request, Page Cannot Be Displayed, aka site doesn't exist).
为什么?
很明显,IIS Express正在努力使用该名称映射或使用端口443,但是为什么呢?
Clearly IIS Express is struggling to map or use port 443 with this name, but why?
applicationhost.config:
<site name="MyDomain" id="16">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\MyDomain" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:MyDomain.local" />
<binding protocol="https" bindingInformation="*:443:MyDomain.local" />
</bindings>
</site>
托管文件:
127.0.0.1 MyDomain.local
VS项目属性:
开始网址",项目网址"和替代"应用程序根URL均为https://MyDomain.local
.
Start Url, Project Url, and Override application root URL are all https://MyDomain.local
.
单击Create Virtual Directory
不会导致任何错误,因为它对applicationhosts.config中的配置感到满意.
Clicking Create Virtual Directory
results in NO errors because it is happy with the config in applicationhosts.config.
注意:仅使用上述设置,http://mydomain.local
(端口80)就可以正常工作!
NOTE: with the above settings alone, http://mydomain.local
(port 80) works fine!
此外,查看项目节点上的属性窗口,所有设置均符合预期:
Further, looking at the properties window on the project node, all settings are as expected:
SSL Enabled: True
SSL URL: https://mydomain.local
URL: http://mydomain.local
此外,在任务栏中查看IIS Express,它们分别显示为443和80.
Also, looking at IIS Express in the task bar, these show up as expected for 443 and 80 respectively.
要成为忍者:
这不是必须的(似乎http://不用这样做是如何工作的),但是我为此运行了netsh只是为了确保URL已注册:
It should not be necessary (seems how http:// works without doing this), but I ran netsh for this just to be sure the URL is registered:
netsh http add urlacl url=https://MyDomain.local:443/ user=Everyone
这当然会导致错误"...已经存在".所以我跑:
This of course results in an error "... already exists". So then I run:
netstat -o
TCP 127.0.0.1:80 mydomain:2063 ESTABLISHED 4
TCP 127.0.0.1:2063 mydomain:http ESTABLISHED 2276
...
我看不到端口443上有任何驻留.否,这台计算机上未安装Skype! (一个常见的问题).
I see nothing camping on port 443. No, Skype is not installed on this machine! (a supposedly common issue).
我全神贯注.有没有搞错?这不是火箭科学.
I am at a total loss. What the heck? This is not rocket science.
环境:
- Windows 10
- VS 2013 Update 5(以管理员身份运行)
其他信息:
我对此进行了疯狂的研究.关于堆栈溢出和其他地方的许多文章.这里只是几个主要的东西:
I have researched this like crazy. Many articles on Stack Overflow and elsewhere. Here are just a couple of prime ones:
和 http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
我已经尝试了所有可以看到的符合逻辑的事情.对于我提出的问题,解决方案是设置我刚刚描述的所有设置.由于这行不通,因此它需要一个单独的帖子!
I have tried everything I can see that is logical to do. For the issue I am raising, the resolution is to set all the settings I just described. Since that doesn't work, it warrants a post of its own!
我想念什么?
推荐答案
基于下面的链接博客,您需要将证书绑定到端口443.IISExpress已将端口44300到44399绑定到本地https的本地证书.发展.
Based on the linked blog below, you need to bind a certificate to port 443. IIS Express has already bound ports 44300 to 44399 to a local certificate for local https development.
我还没有尝试过,但是(该博客的底部)显示了如何将IISExpress用于端口44300到44399的现有本地证书绑定到端口443.
I have not tried it, but (the bottom section of) this blog shows how you can bind to port 443 the existing local certificate IISExpress uses for ports 44300 to 44399.
运行使用SSL和通配符子域的443端口上的IISExpress
这篇关于为什么SSL 443无法在IIS Express中用于Visual Studio Web项目的自定义域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!