-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor SSR rendering on navigation with JS interop/styling #52179
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 want to add that we noticed a problem with loading of styling in our blazor app as well but without webassembly. The only way to consistently reproduce it for us is if we use IIS Deploy and the page auto opens after successful publishing, then there will be no style. Only refreshing the page will finally load the style. |
I just found the source of the problem. I was using the WebOptimizer and publishing my Blazor App to IIS using the publish function of Visual Studio. For whatever reason on the first connection of a device the WebOptimizer tries to acces the obj folder which is not published with the app. It fails and this causes an entire stream of weird exceptions and every ressource failes with either 500 or 404. The event log for the first requested file states that the WebOptimizer can't acces a path which should not even be present as far as i understand it (i mean by publishing to iis, there is no obj folder):
After removing the WebOptimizer from the project everything is fine. |
@javiercn here is a minimal repro (repo): https://github.com/ladeak/Minimal A standard blazor app with one webassembly interactive component leveraging a BlazorMonaco component in this case. Recording.2023-11-23.221551.mp4 |
@ladeak thanks for the additional details. This is what's happening.
Is injecting the style.css script into the page via a script tag when the script runs, which won't work in scenarios with enhanced navigation because scripts are only loaded and run once. There are a couple ways to go about this, but it requires updates to the library:
|
Thank you for the suggestion, I understand now the issue better, and will take the suggested ways. |
Is there an existing issue for this?
Describe the bug
I have a blazor SSR rendered page, that has a single WebAssembly component that renders something with the help of JavaScript.
When I navigate to another page (same setup, SSR + a single WebAssembly component) two things happen:
Expected Behavior
Scroll should reset the position.
All styling I'd expect to load. (If I do an F5 on the same pages, the style is picked up correct).
Steps To Reproduce
It seems to happen only navigation with anchor tags.
Exceptions (if any)
I did not observe any on the conosle.
.NET Version
8.0.100
Anything else?
No response
The text was updated successfully, but these errors were encountered: