简体   繁体   English

如何更改 .net core 中 index.html 的默认路径?

[英]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:我使用 .net core 和 Angular Cli,所以 ngx 的默认结构是:

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

and so on.等等。

I need to change the default path from wwwroot to我需要将默认路径从 wwwroot 更改为

wwwroot/dist/project_name/ wwwroot/dist/project_name/

How do I change the default path of index.html in .net core?如何更改 .net core 中 index.html 的默认路径?


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.实际上,我愿意使用 .net 为 dev 和 prod 模式设置两个路径变量,并将其更改为与 ngx 模式 ng serve 和 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:在启动时的配置方法中,您可以提供像这样的 StaticFileOptions:

    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进一步阅读: https : //docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 asp.net core 中将 index.html 设置为默认页面 - Setting index.html as default page in asp.net core .NET 6 WebApi:如何打开 Swagger 索引。html 默认在 Z5DA5ACF461B4EFB27E76EC8610566 上 - .NET 6 WebApi: how to open Swagger index.html by default on IIS 带有 React 模板的 ASP.NET Core 返回 index.html - ASP.NET Core with React template returns index.html ASP.Net Core - 动态生成 index.html - ASP.Net Core - Dynamically generate index.html 如何使用 controller 或在 ASP.NET Core MVC 中查看 wwwroot 文件夹中的 index.html 文件 - How to render index.html file that is in wwwroot folder using controller or view in ASP.NET Core MVC 如何使用 ASP.Net Core @Html.DropDownListFor 指定默认选项? - How do I specify default option with an ASP.Net Core @Html.DropDownListFor? ASP.Net Core 3:如何使 @Html.DropDownListFor 具有默认值的“只读”? - ASP.Net Core 3: How do I make an @Html.DropDownListFor “read-only” with a default value? Asp.net core 5、使用Identity,如何更改[Authorize]属性的默认重定向? - Asp.net core 5, using Identity, how do I change the default redirect of the [Authorize] Attribute? index.html 未显示为默认页面 - index.html not showing as default page 如何防止最终用户更改 asp.net 内核中 html 标签的值? - how do I prevent end-user to change values from html tags in asp.net core?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM