i'm trying to build a web app with asp.net core for back-end side and angular 1.5.x for front-end side. the problem is haw to enable angular routes to be analyzed by the server. i added these lines of code to the startup.cs and evry thing works fine:
DefaultFilesOptions options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("Index.html");
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = "/Index.html";
await next();
}
})
.UseCors("AllowAll")
.UseDefaultFiles(options)
.UseStaticFiles()
.UseIdentity()
.UseMvc();
but i looks like it's not a good practice, and this problem should be solved in the appsettings.json. any ideas ?