Skip to content

Follow up on: UseEndpoints behaves differently in Development and Production env #44545

@PeterDraex

Description

@PeterDraex

As the original issue (#44491) was closed, I'm opening a follow up issue.

Context
Hosted Blazor WebAssembly

The following two middleware pipeline definitions behave differently.

app.MapRazorPages();
app.MapControllers();
app.MapFallbackToFile("index.html");

and

app.UseEndpoints(endpoints =>
{
    endpoints.MapRazorPages();
    endpoints.MapControllers();
    endpoints.MapFallbackToFile("index.html");
});

The first code chunk works well in all environments. The second works only in Development environment, unless builder.WebHost.UseStaticWebAssets(); is enabled.

Questions

  • Can you help me better understand the difference between the two code chunks above? Why is the call to endpoints.UseStaticWebAssets not necessary with the first code, but is necessary with the second code?
  • Is it safe to enable builder.WebHost.UseStaticWebAssets(); in Production environment? Documentation advises against enabling this in production for Blazor Server apps. Is the recommendation different for WebAssembly apps? Why?
  • If it is not safe to enable, is there any other way to serve multiple Clients from one Server app?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions