I have a .NET 8 Blazor App (or more accurately one created with MudBlazor Web App template) that runs in WebAssembly mode. There is a decently large JSON file (about 7MB, 170k lines) that I need to read and deserialize, and it's just an array of objects. The issue is actually reading the file itself, as I have tried several methods and none seem to work. They all result in the same thing which is that I don't get any "real" exception rather I hit some breakpoint deep inside .NET. The exception itself is massive and in code so pasting it here wouldn't make sense (or look good) but the file itself has the name localhost:5019/_framework/dotnet.native.8.0.2.(random numbers and letters).js [dynamic] and the code breakpoint starts with
var Module=typeof createDotnetRuntime!="undefined"?createDotnetRuntimebefore returning whatever that is.
As I understand it you can't read JSON files in WebAssembly mode the same way you would "normally" do them due to safety issues so I tried HttpClient as some online tutorials suggest it.
protected override async Task OnParametersSetAsync(){ _isLoading = true; List<YrkesbarometerRoot> prognosisRoots = await Http.GetFromJsonAsync<List<YrkesbarometerRoot>>("samplesData.json"); PrognosisGroupedByName = prognosisRoots.GroupBy(ybr => ybr.YbName); _professionCategories = prognosisRoots.Select(ybr => ybr.YbCategory).Distinct().ToList(); FilterPrognosisGroups(); _isLoading = false;}I have also tried reading the file with other ways that you would normally do like File.OpenRead but all of these result in the same issue.