visual-studioiis

How can i have an IIS-debuggable frontend and backend app share the same app pool?


Using Visual Studio i created a backend app.
What i want is that i have a frontend app serving at /
and a backend app that's serving under /api (for example).
both of them should share the same app pool and should be easily deployable to azure and it should be possible to debug it using the IIS command in launchsettings.json

IIS-wise i'm able to configure it. i have a web.config in my sln root and have a handler registered at api/* for aspnetcore app, and one more at * for static files in that order.

now the problem is, the root path of the created app will be my .sln root, so when debugging my backend app, it will tell me there is another application at localhost/ and it wants to rewrite the path, which is wrong.

but when i now try to put my frontend into the csproj folder, then i would only reach it via /frontend, which is of course bad.

I even tried URL Rewrite even though i'd prefer to not have to resort to it, but when i did, it just gave me "something is wrong with your configuration" with empty spaces in the section where it should write the broken code, so i have no idea what was wrong.

what i definitely don't want is to serve my frontend via .UseStaticFiles(), because if i understand correctly, this'd require the .net application to be running when the frontend is.

i hope someone that knows about IIS can help me, thanks already.


Solution

  • If I correctly understood,

    The solution is With the IIS HTTP Redirect module, redirect "/" to "/frontend" but when enabling HTTP Redirect choose "Only redirect requests to content in this directory (not subdirectories)" checkbox so that subfolders do not inherit this redirection. Therefore http requests to api folder will not be redirected.