如何更改.net core 中index.html 的默认路径?
How do I change the default path of index.html in .net core?
我使用 .net core 和 Angular Cli,所以 ngx 的默认结构是:
dist/project_name/index.html
src/index.html
等等。
我需要将默认路径从 wwwroot 更改为
wwwroot/dist/project_name/
如何更改.net core中index.html的默认路径?
实际上,我愿意为 dev 和 prod 模式使用 .net 设置两个路径变量,并将其更改为在 ngx 模式 ng serve 和 ng build 中使用它。也许你可以建议我一些最佳实践,我该怎么做。
在启动时的配置方法中,您可以像这样提供 StaticFileOptions:
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "MyStaticFiles")),
RequestPath = "/StaticFiles"
});
延伸阅读:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.1
我使用 .net core 和 Angular Cli,所以 ngx 的默认结构是:
dist/project_name/index.html
src/index.html
等等。
我需要将默认路径从 wwwroot 更改为
wwwroot/dist/project_name/
如何更改.net core中index.html的默认路径?
实际上,我愿意为 dev 和 prod 模式使用 .net 设置两个路径变量,并将其更改为在 ngx 模式 ng serve 和 ng build 中使用它。也许你可以建议我一些最佳实践,我该怎么做。
在启动时的配置方法中,您可以像这样提供 StaticFileOptions:
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), "MyStaticFiles")),
RequestPath = "/StaticFiles"
});
延伸阅读: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.1