
3.0之前的IHostingEnvironment在net core3.0中过期了应该使用IWebHostEnvironment
- private readonly IWebHostEnvironment _webHostEnvironment;
- public ResourceManagerController(IWebHostEnvironment webHostEnvironment)
- {
- _webHostEnvironment = webHostEnvironment;
- }
使用的时候:
- //获取项目的根目录
- string rootpath = _hostingEnvironment.ContentRootPath;
- //获取存储静态资源的wwwroot所在的根目录
- string webRootPath = _hostingEnvironment.WebRootPath;
评价