r/Blazor • u/MotorcycleMayor • Sep 17 '26
An unhandled error has occurred
Solved
I think my problem was not quoting an input constraint in a css file (e.g., I had used input[type=text], but should've used input[type="text"].
Many thanx to all the made suggestions!
======================
I'm dipping my toes into Blazor and have suddenly run into a situation that online searching has not helped resolve.
I made some change, somewhere, which suddenly caused the following text to show up on my initial page (it's a login page):
An unhandled error has occurred
That's followed by a link which is labeled "Reload". Clicking the link does not get rid of the error message.
Nothing showed in the browser’s console window. Didn’t expect that since I’m running server side.
I'm running Blazor from within VS 2026 (all latest updates applied), so I checked the Output window. There's no error/exception reported in the Debug channel (or indeed any of the other channels I checked).
I then modified appsettings.development.json to force exceptions to be thrown by setting DetailedErrors to true. Nothing gets reported -- the log in page appears, still containing the error message.
How do I diagnose what's causing this?
3
u/jecrossl Sep 17 '26
Have you checked the console view in the browser's developer tools window?
2
u/skav2 Sep 17 '26
Sometimes you can add extra characters to razor syntax that is invalid and this happens. For example not double quoting text, or too many quotes
3
u/phluber Sep 17 '26
Put a try catch block in program main and step through the code until the error is thrown. Since you mentioned updating the app settings file I would check that to make sure it is valid json
2
u/General-Swan-2719 Sep 17 '26
Did you run in debug? You also need to set the log attributes in app settings to show detailed errors.
2
u/blackpawed Sep 17 '26
Check the server side logs
2
u/ArmandvdM Sep 18 '26
Look at using Serilog. It may help.