Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core Virtual directory in IIS Express

i created two aspnet core web and api projects under 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 modified .vs\config\applicationhost.config file like below to use 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 url localhost:29999/api while debugging, i'm getting 404 not found error (where localhost:29999/ is working fine)

But when i deploy the same to dev server by creating virtual directory in IIS, its working fine. so how can i fix this to work with IIS Express

like image 581
Ja9ad335h Avatar asked Mar 24 '16 15:03

Ja9ad335h


1 Answers

The issue here is that the virtual directory is not being recognised as it is Kestrel that is handling this and not actually IIS Express. Basically, Kestrel doesn't know that the Virtual Directory exists, so it cannot serve it up as such.

The answer here, and subsequent blog post link provided in the answer led me to this conclusion and to solve this issue that I too encountered.

like image 59
xrisdoc Avatar answered Oct 15 '22 04:10

xrisdoc