asp.net-core - 带有 Angular 5 的 ASP.NET Core -- 何时使用 Assets 文件夹与 wwwroot 文件夹?

标签 asp.net-core visual-studio-2017 angular5

在 ASP.NET Core 中使用 Angular 5 时,一个新的 Visual Studio 项目包含一个 wwwroot 文件夹和一个 assets 文件夹:

wwwroot and assets

问题是:静态内容(图片、css 等)应该放在哪个文件夹中,你会在什么时候使用一个和另一个?

根据 answers在线,wwwroot 文件夹是静态内容应该去的地方:

The wwwroot folder is new in ASP.NET 5.0. All of the static files in your project go into this folder. These are assets that the app will serve directly to clients, including HTML files, CSS files, image files, and JavaScript files.



然而,根据Angular's documentation ,静态内容也可以进入assets文件夹:

You use the assets array in .angular-cli.json to list files or folders you want to copy as-is when building your project.

最佳答案

Angular 中使用和引用的所有静态内容都应归入 Assets 。 ASP.NET Core 中 MVC View 中使用的所有静态内容都应直接转到 wwwroot。

在构建/部署/发布期间,构建的 Angular 应用程序将自动复制到 wwwroot,因为这是 ASP.NET Core 应用程序静态内容的根文件夹。 (因此 Angular 工件从 ASP.NET Core View 变为静态内容。但您不需要手动执行此操作。)

关于asp.net-core - 带有 Angular 5 的 ASP.NET Core -- 何时使用 Assets 文件夹与 wwwroot 文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47935220/

相关文章:

azure - 使用 Azure Devops 将控制台应用程序部署到 Azure VM 上的文件系统

asp.net-core - 安装 .NET Core 运行时和 SDK 后需要重新启动吗?

c# - Xamarin.iOS 未处理错误启动软调试器 :System. NotSupportedException

c++ - 使用 CMake 构建 project.sln 时发布构建事件错误

c# - 尚未为此应用程序配置 session 或使用 IHttpContextAccessor 时请求错误

c# - 如何设置环境名称(IHostingEnvironment.EnvironmentName)?

mysql - 微软 Visual Studio 2017 Mac : Where is server explorer?

angular - 使用函数中的 subscribe 来测试 Observable

javascript - 在模板 ANGULAR5 中显示数据(对象)的最佳方式

javascript - 选择选项的自定义属性并从 Angular 5 中的 AbstractControl 访问它?