-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Performing JSInterop call during pre-rendering results in a null ref #13396
Comments
I don't know if there is another issue for this but I get the same exception even when I invoke js from I have a reusable component in a razor library:
The js-code is just this:
Consumed by a client side blazor application (without backend), everything works as expected.
This always occures when directly going to the page this component is on. If you navigate there later using a FYI I have also noticed the exact same behaviour when using So there are two issues:
You can apparently work around this error if you use
This workaround doesn't affect client side although you can already see the rendered content before the prompt pops up. In server side, the behaviour is now the same as in client side. |
Another option is to check if the client connection is already established, like below shows:
You can refer to https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-3.0#server-side for the detail. |
Expect: Pretty printed exception message that says you can't do this when the app is pre-rendering
Actual:
The text was updated successfully, but these errors were encountered: