Daryl
Blazor Pages rendering before async methods finish, breaking the page?
The below code is crashing my app because
applicationUser
is null when it's referenced in the HTML. This is a common issue I keep facing, how are you meant to handle it?
I thought the while loop would ensure that it can never continue but I guess it continues because it's returning a Task
?
ChatGPT suggests I added a Delay of 200ms after the command but it doesn't really feel like it would guarantee the issue is solved.
Thanks!153 replies
✅ Managing JSON which varies in size and/or structure?
I'm working on two hobby projects at the moment, both are meant to accept json input but I'm struggling because C# seems quite strict on datatypes and I'm a noob.
In one project the JSON I return is massive and seems like it could be broken into multiple classes.
In the second project, the JSON structure seems to vary depending on the data being sent.
What's the best way to tackle these sorts of things? I appreciate there is a way to copy JSON into Visual Studio it can generate the class for you but I don't want to be tied to Visual Studio and it's still a lot of admin work.
For the varying JSON I captured about 100 entries and put them in a text file but I'm not even sure now how to compare them against each other to see if they're the same structure? Also apparently System.Text doesn't support the "dynamic" data type but Newtonsoft.Json is a thing of the past now?
Any advice or tips would be great, thank you!
84 replies
Method works when dependent Method never called?
I am following a Pluralsight tutorial on ASP.NET Fundamentals and we've just created this hard-coded data repository to work from:
I understand what both of these methods do but I don't understand how the
PiesOfTheWeek
method would currently work as the AllPies
has never been called and not called in any constructor? I would expect PiesOfTheWeek
to return Null when it tries it's Where statement.
Also, shouldn't AllPies
have ()
when it's used in PiesOfTheWeek
?
Thank you in advance!150 replies