IIS Express中的ASP.NET核心虚拟目录

Ja9*_*35h 7 debugging web-config iis-express visual-studio-2015 asp.net-core

我使用VS2015在一个解决方案下创建了两个aspnet核心web和api项目

src
|
|-app.web
|  |-localhost:29999/
|  |-startup.cs 
|  
|-app.api
   |-localhost:29999/api/
   |-startup.cs (app.Map("/api", api => { /*configs and route*/ });)
Run Code Online (Sandbox Code Playgroud)

和修改后的.vs\config\applicationhost.config文件如下所示使用虚拟目录

<site name="ThreeCON.Web" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
      <virtualDirectory path="/" physicalPath="C:\proj\src\app.web\wwwroot" />
      <virtualDirectory path="/api" physicalPath="C:\proj\src\app.api\wwwroot" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:29999:localhost" />
    </bindings>
</site>
Run Code Online (Sandbox Code Playgroud)

当我尝试localhost:29999/api 在调试时访问url ,我收到404 not found错误(哪里localhost:29999/工作正常)

但是,当我通过在IIS中创建虚拟目录将其部署到开发服务器时,它的工作正常.那么我该如何解决这个问题才能使用IIS Express

xri*_*doc 5

这里的问题是无法识别虚拟目录,因为处理此问题的是 Kestrel,而不是实际的 IIS Express。基本上,Kestrel 不知道虚拟目录的存在,因此它无法提供它。

此处答案以及答案中提供的后续博客文章链接使我得出了这个结论并解决了我也遇到的这个问题。