通过 Visual Studio 在同一端口上运行多个 IIS Express 实例

发布于 2024-11-05 22:51:30 字数 1458 浏览 4 评论 0原文

目前,我在 IIS Express 中为我正在开发的每个应用程序配置了站点。它们中的每一个都设置为在端口 80 和 443 上本地运行,但具有单独的绑定(http://site1/http://site2/),这些别名从我的主机文件中指向本地。

我可以在直接(从命令行)启动 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 的限制吗?如果是,有什么好的解决方法吗?

I currently have sites configured in IIS Express for each of the applications I've been working on. Each of them are set to run locally on ports 80 and 443, but have separate bindings (http://site1/ and http://site2/) with those aliases pointing locally from within my hosts file.

I can start these sites at the same time when launching IIS Express directly (from the command line), but letting VS2010 launch them when debugging is unsuccessful. The first site will launch and debug as it should, but the second site to start generates an error: "Unable to launch the IIS Express Web server. Port '80' is in use."

Here's the IIS Express configuration I'm using (slightly modified to remove project names):

<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>

It would appear that VS is doing a check for anything currently listening on port 80, whereas IIS Express isn't restricted in that fashion. I can still have VS attach to the instances of IIS Express that were started by command line, but I'd prefer to have VS manage them.

Is this a limitation on how VS2010 handles IIS Express, and if so, what's a good workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱的十字路口 2024-11-12 22:51:30

你是对的...这是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/site1http://localhost/site2 访问它们

You are right... this is VS2010 limitation. I am not sure if the following workaround works for you or not.

You can have single site with multiple applications as shown below.

<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>

and then you can access them as http://localhost/site1 and http://localhost/site2

开始看清了 2024-11-12 22:51:30

在同一端口 Visual Studio 的情况下,每个站点的绑定收集的开始似乎是一个错误。
从 Visual Studio 运行可以通过添加指定不同端口的绑定来完成。

<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>

<绑定协议=“http”绑定信息=“*:44300:Site1”/>

<绑定协议=“http”绑定信息=“*:44301:Site2”/>

运行 http://Site1/ http://Site2/http://Site1:44300/ http://Site2:44301

netsh http add urlacl url=http://Site1:44300/

beginning of binding collection of each site seems to be an error in the case of same port visual studio.
Run from the visual studio was can be done by adding a binding that specifies the different ports.

<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" />

Running http://Site1/ http://Site2/ and http://Site1:44300/ http://Site2:44301

netsh http add urlacl url=http://Site1:44300/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文