我使用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*/ });)
并修改如下的
.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>
当我在调试时尝试访问URL
localhost:29999/api
时,出现404 not found
错误(其中localhost:29999/
正常工作)但是,当我通过在IIS中创建虚拟目录将其部署到开发服务器时,其工作正常。所以我该如何解决这个问题以与IIS Express一起使用
最佳答案
这里的问题是虚拟目录未被识别,因为是Kestrel处理此目录,而不是IIS Express。基本上,Kestrel不知道虚拟目录是否存在,因此它无法像这样提供服务。
答案中提供的answer here和随后的博客文章链接使我得出了这个结论,并解决了我也遇到的这个问题。
关于debugging - IIS Express中的ASP.NET Core虚拟目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36203922/