I'm running ASP.NET Core MVC for the API calls. Routing: api/* Also running Angular 5.x with its own routing model.
Things work great running localhost (Core runs port 5000 and angular 4200). But when the project is released on Azure everything runs on port 443.
When the application is released all routing goes through the ASPNET Core routing causes 404 when deep linking.
How do I configure the ApplicationBuilder to redirect the Angular routing to Angular?
update:
Links to API:
- /api/event/{id}
- /api/event/{id}/thing
Links to angular:
- / --> (home)
- /event/{key}
- /event/{key}/thing
When traveling from the Home (/) page and using the angular routing the user redirects to /event/{key} which works. When refreshing (F5) the API routing kicks in and returns 404 (because the api doesn't understand).
update2:
This is the fix:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc(); // <-- moved to top (was on bottom)
app.UseStatusCodePagesWithReExecute("/"); // <-- added to redirect to angular
app.UseDefaultFiles();
app.UseStaticFiles();
}
wwwrootroot folder which is always registered first before the MVC middleware (unless you changed that which would make not much sense)