I have an ASP.NET Core application using the Angular Template and ever since I upgraded from .NET Core 3.1 to 5 the app has started returning error 401 when the user refreshes de browser.
The error occurs if the route name matches the name of a controller in the API e.g. route: localhost/produts and controller ProductsController.
If the user navigates to localhost/products from inside the angular app, it works property since it's handled by angular router, but if the url is typed into the address bar or if the user refreshes the browser while on the route, then I get 401 and I believe it's because the route is being interpreted by the ASP.NET Core application.
What used to happen before was the ASP.NET Core app would return the index.html from the angular app, thus reloading the app on the user's browser.
Steps to reproduce:
- On Visual Studio, Create a new "ASP.NET Core With Angular" Project and select .NET 5 as target framework;
- Modify the generated Angular app, change the route 'fetch-data' to 'weatherforecast'. You'll have to modify the following files: app.module.ts and nav-menu.component.html;
- Start Debugging, navigate to Fetch-Data, and then hit F5;
I can't quite figure out why this behavior has changed. Any ideas?