I think there is a better way than using URL rewriting in the routing setup (so there is no need to rewrite the URL at all). For instance. I have done this:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "api",
template: "api/{controller}/{action}");
routes.MapRoute(
name: "angular",
template: "{*url}",
defaults: new {controller = "Home", action = "Index"},
constraints: new {url = new DoesNotContainConstraint(".", "api/") });
});
, /api , - Index. DoNotContainConstraint, , api URL- , .