--- title: ASP.NET Core Blazor environments author: guardrex description: Learn about environments in Blazor, including how to set the environment of a Blazor WebAssembly app. monikerRange: '>= aspnetcore-3.1' ms.author: riande ms.custom: mvc ms.date: 12/11/2020 no-loc: [Home, Privacy, Kestrel, appsettings.json, "ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR] uid: blazor/fundamentals/environments --- # ASP.NET Core Blazor environments > [!NOTE] > This topic applies to Blazor WebAssembly. For general guidance on ASP.NET Core app configuration, which describes the approaches to use for Blazor Server apps, see . When running an app locally, the environment defaults to Development. When the app is published, the environment defaults to Production. The client-side Blazor app (**`Client`**) of a hosted Blazor WebAssembly solution determines the environment from the **`Server`** app of the solution via a middleware that communicates the environment to the browser. The **`Server`** app adds a header named `blazor-environment` with the environment as the value of the header. The **`Client`** app reads the header. The **`Server`** app of the solution is an ASP.NET Core app, so more information on how to configure the environment is found in . For a standalone Blazor WebAssembly app running locally, the development server adds the `blazor-environment` header to specify the Development environment. To specify the environment for other hosting environments, add the `blazor-environment` header. In the following example for IIS, the custom header (`blazor-environment`) is added to the published `web.config` file. The `web.config` file is located in the `bin/Release/{TARGET FRAMEWORK}/publish` folder, where the placeholder `{TARGET FRAMEWORK}` is the target framework: ```xml ... ``` > [!NOTE] > To use a custom `web.config` file for IIS that isn't overwritten when the app is published to the `publish` folder, see . Obtain the app's environment in a component by injecting and reading the property. `Pages/ReadEnvironment.razor`: ::: moniker range=">= aspnetcore-5.0" [!code-razor[](~/blazor/common/samples/5.x/BlazorSample_WebAssembly/Pages/environments/ReadEnvironment.razor?highlight=3,7)] ::: moniker-end ::: moniker range="< aspnetcore-5.0" [!code-razor[](~/blazor/common/samples/3.x/BlazorSample_WebAssembly/Pages/environments/ReadEnvironment.razor?highlight=3,7)] ::: moniker-end During startup, the exposes the through the property, which enables environment-specific logic in host builder code. In `Program.Main` of `Program.cs`: ```csharp if (builder.HostEnvironment.Environment == "Custom") { ... }; ``` The following convenience extension methods provided through permit checking the current environment for Development, Production, Staging, and custom environment names: * * * * In `Program.Main` of `Program.cs`: ```csharp if (builder.HostEnvironment.IsStaging()) { ... }; if (builder.HostEnvironment.IsEnvironment("Custom")) { ... }; ``` The property can be used during startup when the service isn't available. ## Additional resources *