本文介绍了ASP.NET Core中的HttpRuntime.AppDomainAppPath等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
.NET Core中HttpRuntime.AppDomainAppPath
的等效项是什么?我将项目从ASP.NET移到了核心,但其中不包含一些库(例如System.Web
).这是一个小例子:
What is the equivalent of HttpRuntime.AppDomainAppPath
in .NET Core? I moved a project from ASP.NET to core, and a few Libraries are not included (Such as System.Web
). Here is a small example:
sb.AppendLine("\"New Path\": \"" + newFile.FullName.Replace(HttpRuntime.AppDomainAppPath, "/");
任何帮助将不胜感激,谢谢
Any help would be appreciated, thanks
推荐答案
IHostingEnvironment
界面提供有关环境的信息,包括基本路径(文档).您可以使用依赖注入获得实例.
The IHostingEnvironment
interface provides information about the environment including the base path (documentation). You can get an instance using dependency injection.
public class Startup
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// env.ContentRootPath;
}
}
这篇关于ASP.NET Core中的HttpRuntime.AppDomainAppPath等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!