All examples of using AngularJs with MVC6 / vNext / .NET5 use the static index.html file, which is located inside wwwroot. Did this, but now I need to load the MVC index.cshtml page so that I can add the parameters that are in my config.json to the page.
All I want is the default (Home) page, which loads no matter what URL is requested, provided that the URL is not a js / css file or api controller.
I tried adding this to my method Configure(IApplicationBuilder app, IServiceProvider serviceProvider)
, but now my js and css files completely canceled the Home / Index.cshtml file
app.UseMvc(options =>
{
options.MapRoute("Api",
template: "api/{version}/{controller}/{action?}",
defaults: new { version = "v1", controller = "Page" });
options.MapRoute(
name: "default",
template: "{*url}",
defaults: new { controller = "Home", action = "Index" });
});
http://localhost:port, . angularJs URL-,
http:
http:
http:
http:
Home/Index.cshtml angular .
- web.config, IIS,
, js/css, . angular, .
app.UseMvc(options =>
{
options.MapRoute("Api",
template: "api/{version}/{controller}/{action?}",
defaults: new { version = "v1", controller = "Page" });
options.MapRoute(
name: "default",
template: "{controller}/{action?}",
defaults: new { controller = "Home", action = "Index" });
});
2
public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider)
{
app.RegisterMappingFiles();
app.UseStaticFiles();
app.UseMvc(options =>
{
options.MapRoute(
name: "default",
template: "{controller}/{action?}",
defaults: new { controller = "Home", action = "Index" });
});
}