简体   繁体   中英

How do I change the default path of index.html in .net core?

I use .net core with Angular Cli, so the default structure of ngx is:

dist/project_name/index.html
src/index.html

and so on.

I need to change the default path from wwwroot to

wwwroot/dist/project_name/

How do I change the default path of index.html in .net core?


Actually, I'm willing to set two path variables with .net for dev and prod modes and change it for using it with both ngx modes ng serve and ng build. Maybe you can advice me some best practice how can I do it.

In the Configure Method in startup you could provide StaticFileOptions like this:

    app.UseStaticFiles(new StaticFileOptions
{
    FileProvider = new PhysicalFileProvider(
        Path.Combine(Directory.GetCurrentDirectory(), "MyStaticFiles")),
    RequestPath = "/StaticFiles"
});

Further reading: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM