Primary ASP.NET Virtual Directory in IIS Express

I created two aspnet core and api projects in one solution using VS2015

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

and a modified .vs\config\applicationhost.config file as shown below to use the virtual directory

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

when I try to access the localhost:29999/api url when debugging , I get a 404 not found error (where localhost:29999/ works fine)

But when I deploy the same dev server, creating a virtual directory in IIS, it works fine . so how can I fix this to work with IIS Express

+6
source share
1 answer

The problem here is that the virtual directory is not recognized, since it is Kestrel that handles this, and not actually IIS Express. Basically, Kestrel does not know that a virtual directory exists, so it cannot serve it as such.

The answer here and the following blog link provided in the answer led me to this conclusion and resolved this problem that I encountered.

+1
source

All Articles