Skip to content

[.net 10 Preview 5] Blazor wasm stand-alone app HostEnvironment is "Production" in development mode #62362

Open
@cda-1

Description

@cda-1

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Kestrel doesn't seem to be setting the Blazor-Environment header for stand-alone blazor wasm apps in .net 10. It works fine in .net 8 and 9.

Expected Behavior

We expect that kestrel will somehow get the Environment name into the blazor app. The console statement that logs to the browser should show the very same environment that is logged to the host console as kestrel launches.

It seems there should be a Blazor-Environment header on one of the blazor files, but I couldn't find any that had it. In .net 8 and .net 9 for example, blazor.boot.json has this header set on it. In .net 10 preview, I didn't actually see this file at all.

Steps To Reproduce

Using VIsual Studio 2022 or 2022 preview, create a blazor standalone wasm app using the template. Accept the defaults (no auth, etc) to keep it simple.

In Program.cs, after the line:
var builder = WebAssemblyHostBuilder.CreateDefault(args);

Place:
Console.WriteLine($"Client Hosting Environment: {builder.HostEnvironment.Environment}");

Use dotnet run to launch the app. In all 3 .net versions, it will log to the console:

"info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development"

But when you open your browser and look at its console, this value carried over only in .net 8 and .net 9.

In .net 8 and .net 9 apps, "Development" is logged to the browser console. In .net 10 preview 5 apps, it's "Production" that is logged.

Exceptions (if any)

No response

.NET Version

10.0.100-preview.5.25277.114

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions