-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor WebApp Wasm Hot Reload does not work with UseRouting #52339
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
Comments
I came across this issue and wanted to share that I am experiencing a very similar problem in my Blazor wasm hosted application after migrating to .NET 8. Just like in the case described, I encounter an error stating that the assembly cannot be edited or changed due to the DOTNET_MODIFIABLE_ASSEMBLIES environment variable being set to '(null)', not 'Debug'. I have tried setting DOTNET_MODIFIABLE_ASSEMBLIES to 'Debug' in various ways (including in Program.cs, through system environment variables, and via the command line), but the issue persists. My application's middleware configuration closely follows the recommended pattern, with app.UseAntiforgery() placed correctly between app.UseRouting() and app.UseEndpoints(). Any additional insights or solutions would be greatly appreciated, as this issue is impacting the efficiency of my development process. |
@Solbstr, I would say if you are using the "minimal API approach" (the one with no Startup.cs, whether you have controllers or not does not matter) simply remove
If nothing else just try to remove |
Thanks @Jejuni , seems that hot reload started working again after removal of app.useRouting(). |
To learn more about what this message means, what to expect next, and how this issue will be handled you can read our Triage Process document. |
I have the same issue, but removing
Do you guys have any suggestions other than removing |
We have the same issue as @NielsPilgaard. When we remove UseRouting it seems that all css/js-files gets the context of App.razor. Working with frontend without hot-reload and close to no inspection support (children could not be evaluated on every semi-complex model) is getting very costly. Surprised this fix is scheduled for .net9 :( |
I managed to find a workaround, this very specific order of middleware allowed hot reload to work again, with app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery(); |
So, it seems that Not sure if it adds any sort of regression or unwanted behaviour. Might be a quick-fix for local development, so thanks for the tip. |
From my testing it's apparently enough to just place // Other middleware like auth, swagger etc.
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.MapFallbackToFile("index.html");
app.Run(); |
Also ran in to this today, UseBlazorFrameworkFiles() fixes it but as said I thought this was not meant to be used anymore |
Is there an existing issue for this?
Describe the bug
When using the
UseRouting
middleware as described in the migration documentation (the part about addingUseAntiforgery
right afterUseRouting
: https://learn.microsoft.com/en-us/aspnet/core/migration/70-80?view=aspnetcore-8.0&tabs=visual-studio#convert-a-hosted-blazor-webassembly-app-into-a-blazor-web-app) hot reload no longer works and fails with the error mentioned in the Exception sectionExpected Behavior
UseRouting
should continue to function when used with Blazor WebAppSteps To Reproduce
Repro Github: https://github.com/Jejuni/BlazorWebAppRoutingProblem
The repro is simply the default Blazor WebApp Wasm Global Template with
app.UseRouting();
added directly beforeUseAntiforgery
To produce the error start the app via F5, then make a simple change in
Home.razor
and try to hot reloadExceptions (if any)
The browser displays:
.NET Version
8.0.100
Anything else?
Asp.Net Core Version: 8.0.0
IDE: VS 17.8.1
The text was updated successfully, but these errors were encountered: