IIS Express-Visual Studio-在同一端口上运行多个站点 [英] IIS Express - Visual Studio - Running multiple sites on the same port

查看:142
本文介绍了IIS Express-Visual Studio-在同一端口上运行多个站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个使用相同端口的API(8888).这些API是不同解决方案的一部分.

http://localhost:8888/api1

http://localhost:8888/api2

....

当我在Visual Studio 2013(按F5键)中运行任何API时,iis express将启动,并且所有API都在运行.即使API是不同解决方案的一部分,也会发生这种情况.单击查看网站"下的iis Express图标可以看到它们.

我安装了VS 2015,而当我在Visual Studio中运行一个API时,其他API则无法运行.由于出现以下错误,我什至无法运行其他解决方案中的其他API:

 无法启动iis express ..端口正在使用 

运行任何API时如何使其他API运行?我需要在VS 2015中模仿VS 2013中存在的行为.

谢谢.

解决方案

尽管在我的情况下,我选择通过命令行运行IISExpress并通过配置文件作为参数,但我在类似的情况下也解决了此问题.

  1. 编辑applicationhost.config文件.我是通过文件夹路径%USERPROFILE%\ Documents \ IISExpress \ config
  2. 找到的
  3. 找到< sites>部分(位于< system.applicationHost>下)

作为一个例子,我有两个应用程序要同时在localhost的端口80上托管:

 < sites><网站名称="test" id ="1" serverAutoStart ="true"><应用程序路径="/" applicationPool ="Clr4IntegratedAppPool">< virtualDirectory path ="/" physicalPath ="C:\ codepath"/></应用程序><应用程序路径="/api1" applicationPool ="Clr4IntegratedAppPool">< virtualDirectory path ="/" physicalPath ="C:\ codepath \ api1"/></应用程序><应用程序路径="/api2" applicationPool ="Clr4IntegratedAppPool">< virtualDirectory path ="/" physicalPath ="C:\ codepath \ api2"/></应用程序>< bindings>< binding protocol ="http" bindingInformation =:80:localhost"/></bindings></site><!-与IISExpress安装相关的其他设置-></sites> 

要使其正常工作,我要做的关键事情是:

  1. 确保applicationhost.config是格式正确的XML
  2. 确保除了两个api应用程序路径之外,还指定根路径
  3. serverAutoStart ="true"确保在调用IISExpress时启动站点
  4. 所有应用程序共享同一个applicationPool
  5. 我只定义了一个站点,并将所有应用程序捆绑为子路径

I have multiple APIs that use the same port (8888). These APIs are part of different solutions.

http://localhost:8888/api1

http://localhost:8888/api2

....

When I run any of the APIs in visual studio 2013 (hit F5), iis express starts and all of the APIs are running. This happens even though the APIs are part of different solution. I can see them when I click on the iis express icon under View Sites.

I installed VS 2015 and when I run one API in visual studio the other APIs do not run. I cannot even run the other APIs in the other solution since I get:

unable to launch iis express.. port is in use

how can I get the other APIs to run when I run any API? I need to mimic the behavior that exists in VS 2013 in VS 2015.

Thanks.

解决方案

I solved this for a similar scenario, although in my case I chose to run IISExpress via the command line and passed through the config file as an argument.

  1. Edit the applicationhost.config file. I found mine via the folder path %USERPROFILE%\Documents\IISExpress\config
  2. Locate the <sites> section (found under <system.applicationHost>)

As an example, I have two applications that I want to host simultaneously on port 80 on localhost:

<sites>
    <site name="test" id="1" serverAutoStart="true">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\codepath" />
        </application>
        <application path="/api1" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\codepath\api1" />
        </application>
        <application path="/api2" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\codepath\api2" />
        </application>
        <bindings>
            <binding protocol="http" bindingInformation=":80:localhost" />
        </bindings>
    </site>
<!-- other settings  relevant to your installation of IISExpress-->
</sites>

The key things I had to do to get this working was:

  1. Make sure applicationhost.config is well-formed XML
  2. Make sure you specify the root path in addition to the two api application paths
  3. serverAutoStart="true" ensures the site starts when IISExpress is called
  4. All the applications share the same applicationPool
  5. I defined just one site and bundled in all my applications as sub paths

这篇关于IIS Express-Visual Studio-在同一端口上运行多个站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆