更新时间:2023-02-16 16:30:45
您需要注入IHostingEnvironment
.然后:
var path = env.ContentRootPath + "Views\\" + s;
在html助手中,您可以执行以下操作:
in an html helper you can do this:
((IHostingEnvironment)html.ViewContext.HttpContext.RequestServices.GetService(typeof(IHostingEnvironment))).ContentRootPath;