我目前在IIS Express中为我正在处理的每个应用程序配置了站点。它们中的每一个都设置为在端口80和443上本地运行,但具有单独的绑定(http://site1/和http://site2/),这些别名指向我的hosts文件中的本地别名。
我可以在直接启动IIS Express(从命令行)启动这些站点,但是在调试失败时让VS2010启动它们。第一个站点将按预期启动和调试,但第二个站点将启动生成错误:“无法启动IIS Express Web服务器。端口'80'正在使用中。”
这是我正在使用的IIS Express配置(略微修改以删除项目名称):
<site name="Site1" id="1" serverAutoStart="true">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="Site1Path" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:Site1" />
<binding protocol="https" bindingInformation="*:443:Site1" />
</bindings>
</site>
<site name="Site2" id="2" serverAutoStart="true">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="Site2Path" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:Site2" />
<binding protocol="https" bindingInformation="*:443:Site2" />
</bindings>
</site>
看起来VS正在检查当前正在端口80上侦听的任何内容,而IIS Express并不受此限制。我仍然可以将VS附加到由命令行启动的IIS Express实例,但我更愿意让VS管理它们。
这是VS2010如何处理IIS Express的限制,如果是,那么有什么好的解决方法?
答案 0 :(得分:9)
你是对的......这是VS2010的限制。我不确定以下解决方法是否适合您。
您可以拥有包含多个应用程序的单个网站,如下所示。
<site name="MySite" id="1" serverAutoStart="true">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="SiteRoot" />
</application>
<application path="/Site1" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="Site1Path" />
</application>
<application path="/Site2" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="Site2Path" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:Site1" />
<binding protocol="https" bindingInformation="*:443:Site1" />
</bindings>
</site>
然后您可以http://localhost/site1
和http://localhost/site2
答案 1 :(得分:2)
<site name="Site1" id="1" serverAutoStart="true">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="Site1Path" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:44300:Site1" />
<binding protocol="http" bindingInformation="*:80:Site1" />
</bindings>
</site>
<site name="Site2" id="2" serverAutoStart="true">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="Site2Path" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:44301:Site2" />
<binding protocol="http" bindingInformation="*:80:Site2" />
</bindings>
</site>
<binding protocol="http" bindingInformation="*:44300:Site1" />
<binding protocol="http" bindingInformation="*:44301:Site2" />
正在运行http://Site1/
http://Site2/
和http://Site1:44300/
http://Site2:44301
※netsh http add urlacl url=http://Site1:44300/