Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] Update WebAssembly.DevServer to serve the Blazor-Environment header #57971

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MackinnonBuck
Copy link
Member

Since the dev server no longer calls UseBlazorFrameworkFiles(), we need to manually add the Blazor-Environment header when applicable.

Fixes #57941

@MackinnonBuck MackinnonBuck added the area-blazor Includes: Blazor, Razor Components label Sep 19, 2024
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner September 19, 2024 19:08
@MackinnonBuck
Copy link
Member Author

/backport to release/9.0-rc2

Copy link
Contributor

Started backporting to release/9.0-rc2: https://github.com/dotnet/aspnetcore/actions/runs/10949630835

else if (applyCopHeaders && ctx.Request.Path.StartsWithSegments("/_framework") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.server.js") && !ctx.Request.Path.StartsWithSegments("/_framework/blazor.web.js"))
{
var fileExtension = Path.GetExtension(ctx.Request.Path);
if (string.Equals(fileExtension, ".js", StringComparison.Ordinal))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't an analyzer catch this previously? Also, it's more consistent to ignore case.

Suggested change
if (string.Equals(fileExtension, ".js", StringComparison.Ordinal))
if (string.Equals(fileExtension, ".js", StringComparison.OrdinalIgnoreCase))

I can't think of a reason a request would come in with an uppercase .JS extension, but file extensions generally are case insensitive, and the dev server would still serve the correct file. StartsWithSegments also defaults to OrdinalIgnoreCase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blazor WebAssembly Standalone App targeting .net 9 runs in production mode when started from VS in debug mode
4 participants