79515317

Date: 2025-03-17 17:22:12
Score: 1.5
Natty:
Report link

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:

https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/environments?view=aspnetcore-9.0#read-the-environment-in-a-blazor-webassembly-app

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Wynsler