本文介绍了为什么需要在ASP.NET Core MVC中设置"UseContentRoot(AppContext.BaseDirectory)"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么需要在ASP.NET Core MVC中设置 UseContentRoot(AppContext.BaseDirectory)?

Why need to set up UseContentRoot(AppContext.BaseDirectory) in ASP.NET Core MVC?

推荐答案

来自文档(在本例中是我写的):

From the docs (which in this case I wrote):

如果不添加此目录,则内容根目录将默认为应用程序根目录,该目录是程序运行所在的位置(可能在/bin文件夹中的某个位置).如果要从源/项目根目录启动Web应用程序,通常这不是您想要的.

If you don't add this, the content root will default to the application root, which is wherever the program is running from (probably somewhere in a /bin folder). This usually isn't what you want if you're launching the web app from its source/project root.

这篇关于为什么需要在ASP.NET Core MVC中设置"UseContentRoot(AppContext.BaseDirectory)"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 19:44