London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

WebRootPath in DXP

Vote:
 

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


Same thing in a scheduled job

private readonly EPiServer.Web.IWebHostingEnvironment _env;
if(string.IsNullOrEmpty(_env.WebRootPath))
{
 return "Job terminated. WebRootPath is empty!";
}
#338045
May 08, 2025 6:22
Vote:
 

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.

#338047
May 08, 2025 11:53
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.