Troubleshooting Controller in Blazor WASM project NET5 after app modernization

wavemaster 311 Reputation points
2021-05-12T16:33:10.997+00:00

Redid a aspnet core 2.1 Blazor WASM project in NET5, just started from scratch as a I did not manage to follow the upgrade steps provided by Microsoft and we left with tens of error messages.

Initially the NET5 Blazor WASM app worked, but that was days ago and I have not been able to get it working again.

The code hits my .razor page and produces this error:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Value cannot be null. (Parameter 'source')
System.ArgumentNullException: Value cannot be null. (Parameter 'source')
at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Linq.Enumerable.CountUserName
at AccountManager.Client.Pages.Accounts.OnInitializedAsync() in C:\Users\Robert\source\Repos\AccountManager\Client\Pages\Accounts.razor:line 89
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

96045-line89.png

Adding breakpoints does nothing. The above error message pops up in the console and that is it. Without the call to the api, breakpoints work as they should in that code.

Ok, so something is up with the Controller. Comparing things with the aspnet core 2.1 app I see that this WASM project has different launchsettings between .Client and .Server, i.e. the SSL port is different, and when I run the app I have two browser windows.

The new NET5 WASM project has the same SSL port for .Client and .Server.

Is this how things are supposed to be in NET5?

How can I test my API to figure out what is not working right?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
785 questions
{count} votes