AI OnAI Off
Is this an upgraded project from CMS11? In many cases those lack a wwwroot folder which is what WebRootPath will look for. In that case, either specify the path in your startup or use ContentRootPath instead.
Try IWebHostEnvironment.WebRootPath (from the Microsoft.AspNetCore.Hosting namespace).
And also, you can inject IWebHostEnvironment in the Startup constructor, capture it in a private field for use in the ConfigureServices method. Probably also in the Configure method.
Hello,
I'm having trouble getting the WebRootPath to work in DXP, Optimizely 12.
In startup.cs im using this code and it returns an empty string
var epiWebHostingEnvironment = app.ApplicationServices.GetRequiredService<IWebHostingEnvironment>();
epiWebHostingEnvironment.WebRootPath
private readonly EPiServer.Web.IWebHostingEnvironment _env;
if(string.IsNullOrEmpty(_env.WebRootPath))
{
return "Job terminated. WebRootPath is empty!";
}