Skip to content

Retrieving HTML instead of JSON #9

@SamuelWachtel

Description

@SamuelWachtel

Hi, I was trying to recreate this ecommerce step by step by your yt tutorial , but right after including EF core, I tried to launch it but with no success, I am getting HTML instead of JSON when await CategoryService.LoadCategories(); is called. I also tried to download ready made project here, just updated the ef core to work with my db and the result is same, also getting HTML instead of JSON when calling await CategoryService.LoadCategories();

Did anyone else had same issue? Thanks

Sam

Error from dev tools:
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.Serialization.JsonConverter1[[BlazorEcommerce.Shared.ServiceResponse1[[System.Collections.Generic.List1[[BlazorEcommerce.Shared.Category, BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) at System.Text.Json.Serialization.JsonConverter1[[BlazorEcommerce.Shared.ServiceResponse1[[System.Collections.Generic.List1[[BlazorEcommerce.Shared.Category, BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadCore[ServiceResponse1](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadCore[ServiceResponse1](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase) at System.Text.Json.JsonSerializer.ContinueDeserialize[ServiceResponse1](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonConverter converter, JsonSerializerOptions options) at System.Text.Json.JsonSerializer.<ReadAllAsync>d__651[[BlazorEcommerce.Shared.ServiceResponse1[[System.Collections.Generic.List1[[BlazorEcommerce.Shared.Category, BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at System.Net.Http.Json.HttpContentJsonExtensions.<ReadFromJsonAsyncCore>d__41[[BlazorEcommerce.Shared.ServiceResponse1[[System.Collections.Generic.List1[[BlazorEcommerce.Shared.Category, BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at System.Net.Http.Json.HttpClientJsonExtensions.<GetFromJsonAsyncCore>d__131[[BlazorEcommerce.Shared.ServiceResponse1[[System.Collections.Generic.List1[[BlazorEcommerce.Shared.Category, BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at BlazorEcommerce.Client.Services.CategoryService.CategoryService.GetCategories() in C:\Users\samuel.wachtel\OneDrive - Creditinfo Group\Desktop\New folder (3)\BlazorEcommerce-master\BlazorEcommerce-master\BlazorEcommerce\Client\Services\CategoryService\CategoryService.cs:line 52 at BlazorEcommerce.Client.Shared.ShopNavMenu.OnInitializedAsync() in C:\Users\samuel.wachtel\OneDrive - Creditinfo Group\Desktop\New folder (3)\BlazorEcommerce-master\BlazorEcommerce-master\BlazorEcommerce\Client\Shared\ShopNavMenu.razor:line 42 at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions