为什么需要在ASP.NET Core MVC中设置UseContentRoot(AppContext.BaseDirectory)?
解决方法
从
docs(在这种情况下我写的):
Specifying Directory.GetCurrentDirectory as the content root will use the web project’s root folder as the app’s content root when the app is started from this folder (for example,calling dotnet run from the web project folder). This is the default used in Visual Studio and dotnet new templates.
如果不添加此内容,则内容根目录将默认为应用程序根目录,即运行程序的位置(可能位于/ bin文件夹中的某个位置).如果您从源/项目根目录启动Web应用程序,通常不是您想要的.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。