--- 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: 06/10/2020 no-loc: ["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, see . When running an app locally, the environment defaults to Development. When the app is published, the environment defaults to Production. A hosted Blazor WebAssembly app picks up the environment from the server via a middleware that communicates the environment to the browser by adding the `blazor-environment` header. The value of the header is the environment. The hosted Blazor app and the server app share the same environment. For more information, including how to configure the environment, see . For a standalone 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, add the custom header to the published `web.config` file. The `web.config` file is located in the `bin/Release/{TARGET FRAMEWORK}/publish` folder: ```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: ```razor @page "/" @using Microsoft.AspNetCore.Components.WebAssembly.Hosting @inject IWebAssemblyHostEnvironment HostEnvironment

Environment example

Environment: @HostEnvironment.Environment

``` During startup, the exposes the through the property, which enables developers to have environment-specific logic in their code: ```csharp if (builder.HostEnvironment.Environment == "Custom") { ... }; ``` The following convenience extension methods permit checking the current environment for Development, Production, Staging, and custom environment names: * `IsDevelopment()` * `IsProduction()` * `IsStaging()` * `IsEnvironment("{ENVIRONMENT NAME}")` ```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 *