English 中文(简体)
通过Visual Studio在同一端口上运行多个IIS Express实例
原标题:Running multiple IIS Express instances on the same port through Visual Studio

我目前在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的方式?如果是,有什么好的解决方法?

最佳回答

你是对的。。。这是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

问题回答

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>

<;bindingprotocol=“http”bindingInformation=“*:44300:Site1”/>

<;bindingprotocol=“http”bindingInformation=“*:44301:Site2”/>

跑步 <代码>http://Site1/http://Site2/http://Site1:44300/http://Site2:44301

※<code>netsh http添加urlacl url=http://Site1:44300/





相关问题
Best practices for Subversion and Visual Studio projects

I ve recently started working on various C# projects in Visual Studio as part of a plan for a large scale system that will be used to replace our current system that s built from a cobbling-together ...

Enable PHP highlights in VS 2010?

I ve heard that Visual Studio 2010 Beta 2 has support for PHP. When I load a PHP file though, it has nothing highlighted and is nothing more than a glorified text editor. Is there a way to enable it?...

Do I want Publish or Release Build in VB.net?

I wrote a little (like 40 lines little) Winforms application with VB.net in Visual Studio 2010. Now I ve released the code as a Google Code project. It s easy for a developer to get the source but I d ...

Unit Testing .NET 3.5 projects using MStest in VS2010

There s a bug/feature in Visual Studio 2010 where you can t create a unit test project with the 2.0 CLR. https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483891&wa=...

热门标签