I have an ASP.NET Core Blazor web app (.NET9), and have been having problems with a page where the user can upload files. Whenever a file is uploaded, the entire page gets reloaded, which is causing problems.
After a lot of digging, I finally realised that it is (seemingly) nothing to do with my page or controller code. If I have multiple tabs open in my browser, each pointing at different pages in the app, and I manually drop a file into (say) the wwwroot/images folder using Windows File Explorer, then all pages are reloaded. This applies even some tabs show pages being rendered on the server, with other on the client. Similarly, it applies to all tabs, even ones in private/incognito windows with different (or no) users logged in.
At first I thought this was just VS Hot Reload being over-zealous, in which case it wouldn't happen in production. However, the problem happens in production as well.
I haven't posted any code, as I'm not sure what might be useful, as the issue doesn't seem to be related to either the code in the component that does the upload, nor the code in the controller that receives the file.
The only thing I could think of that might have been relevant was that I was calling app.MapStaticAssets() in the server's Program.cs. I changed that to use app.UseStaticFiles but had the same issue.
Anyone any idea how I prevent this from happening?