Blazor NavigationManager throws Unspecified navigation exeption.
So i've just started to learn Blazor. I found that when i try to use the NavigationManager from a form (OnValidSubmit), then it throws:
Microsoft.AspNetCore.Components.NavigationException: 'Exception_WasThrown'
I have not edited any of the setup (program.cs), so i might just be a bug in the framework as there is some bugs on the navigation manager. I have not been able to find any cases exactly like this on their github.
It only throws the exception in Debug, and if i continue, the navigation is executed correctly.
I have also tried to "hack", by using
NavigationManager.NavigateTo()
with the current page as parameter, throws same error.
Does anyone know if this is a known error and if there might be a workaround (or if there is something i am missing).
Code
Exception:
See added image
See first comment for stacktrace.4 Replies
tacktrace:
It throws, but still works? Huh? Are you catching an exception that gets caught by the framework and is ignored, perhaps?
I personally never ran into that issue. What's your .razor look like? Are you using WASM, server, or auto?
I found that you could disable that type if exeption in debug mode. Apparently it is a known thing that the navigator throws an exception and handles it somewhere else. When running without debugging no errors occurs. For now i am not using any interactivity (why i need to call the refresh function)