In ASP.NET 9.x Core Blazor
The IWebHostEnvironment can be accessed from the server-side as follows:
Program.cs
var builder = WebApplication.CreateBuilder(args);
Console.WriteLine($"Content root path: {builder.Environment.ContentRootPath}.");
In this case, we are looking at the default configuration of the content root path.
If you are wanting to access the IWebHostEnvironment from the client-side, then you can follow: