Doesn't store anything. And using await _localStorage.GetItemAsync<List<CartItem>>("cart"); produces this error
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: 'c' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
System.Text.Json.JsonException: 'c' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: 'c' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 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.JsonConverter`1[[System.Collections.Generic.List`1[[BlazorEcommerce.Shared.CartItem, BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].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.JsonConverter`1[[System.Collections.Generic.List`1[[BlazorEcommerce.Shared.CartItem, BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[List`1](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.ReadFromSpan[List`1](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize[List`1](String json, JsonSerializerOptions options)
at Blazored.LocalStorage.Serialization.SystemTextJsonSerializer.Deserialize[List`1](String data)
at Blazored.LocalStorage.LocalStorageService.<GetItemAsync>d__5`1[[System.Collections.Generic.List`1[[BlazorEcommerce.Shared.CartItem, BlazorEcommerce.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
CartItem model:
public class CartItem
{
public int ProductId { get; set; }
public int ProductTypeId { get; set; }
}
But it did work in Google Chrome
EDIT: Okay, that is strange. Chrome does only work, if the Visual Studio has not started it in debug mode. The same goes for the dotnet command. If the dotnet watch was executed the storage did not work,
but with dotnet run it did work. I cleaned an rebuilded my solution now over 10 times. And I also cleaned the whole application storage on all browsers. I don't know what is going on here.
EDIT 2: I restarted my machine, deleted every cache or binary and tried it again. The same result.
Hello experts!
Unfortunately I am unable to use this package to store a List in the LocalStorage in the Microsoft Edge browser. Using
(The razor file)
Doesn't store anything. And using
await _localStorage.GetItemAsync<List<CartItem>>("cart");
produces this errorCartItem model:
But it did work in Google Chrome
EDIT: Okay, that is strange. Chrome does only work, if the Visual Studio has not started it in debug mode. The same goes for the
dotnet
command. If thedotnet watch
was executed the storage did not work,but with
dotnet run
it did work. I cleaned an rebuilded my solution now over 10 times. And I also cleaned the whole application storage on all browsers. I don't know what is going on here.EDIT 2: I restarted my machine, deleted every cache or binary and tried it again. The same result.