Reputation: 3317
I have the following setup:
I would like to host them both in one iis Site so that they are like that:
localhost\Site\ < --- angular app
localhost\Site\Api\ < --- web api app
I tried to run the .net core web api project from a virtual folder but with no luck. Getting a 404 exections
The web api works if I host the Web api project directly (binding the Application path to the \Api folder). But then that app needs to serve also statics files witch It does not whant to do for some reason even doh I enabled:
ConfigureServices
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "App";
});
...
Configuration
app.UseStaticFiles(new StaticFileOptions()
{
OnPrepareResponse = (context) =>
{
// Disable caching for all static files.
context.Context.Response.Headers["Cache-Control"] = Configuration["StaticFiles:Headers:Cache-Control"];
context.Context.Response.Headers["Pragma"] = Configuration["StaticFiles:Headers:Pragma"];
context.Context.Response.Headers["Expires"] = Configuration["StaticFiles:Headers:Expires"];
}
});
Anyone know where I could find some instructions regarding this?
Upvotes: 0
Views: 1235
Reputation: 907
I also had similar issues, and found the .NET Core application and the Angular application had to be configured as separate applications under the same website in IIS. This may be a well known fact, but I couldn't find it stated anywhere
Upvotes: 0
Reputation: 3317
Managed to get it working,
In case someone comes along this this is what worked for me:
1.) Make the Site app pool to work with .net core:
2.) Create an application under the site calling it app
Deploy the angular app to that folder (don't forget to build the angular app with base-href to account for the folder )
Change the web.config
to (have a look at headers.remove ):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<remove name="aspNetCore" />
</handlers>
</system.webServer>
</location>
</configuration>
3.) Create another app under the site calling it backend
for instance:
Deploy the .net core web api app into this folder.
Change the web.config
to (imporant to remove the commented out header section):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<!-- <handlers> -->
<!-- <remove name="aspnetcore" path="*" verb="*" modules="aspnetcoremodule" resourcetype="unspecified" /> -->
<!-- </handlers> -->
<aspNetCore processPath="dotnet" arguments=".\core.rest.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Hope it helps someone
Upvotes: 1