Comments (11)
Ok, so it looks like the changes made to fix #57 and subsequent bug fixes have broken things for others.
I would suggest @soltrac and @daniel-rck go back to an earlier version of the library and I'll have a think about what to do.
from localstorage.
@daniel-rck @soltrac The issues should be resolved in the latest release. Let me know if you experience any further issues.
from localstorage.
Hi @daniel-rck, are you sure it broke with v2.1.4? There were no changes to the SetItem<T>
method only to the GetItem<T>
method. However, v2.1.3 had changes to the SetItem<T>
method.
from localstorage.
On my side there were also no changes besides the LocalStorage-Nuget.
I tested other string, they were working. In fact only my tyical JWT failed. Can I send you the value that you can reproduce the error? I feel unsafe posting it here.
from localstorage.
Yes, please do. Either DM me it on Twitter or there is a contact form on my website via the Speaking page.
from localstorage.
@daniel-rck I've used your JWT in the sample app and it has saved to local storage fine, without any errors.
from localstorage.
I have exactly the same problem.
For example this, in new version this is not working for me. It was working ok on previous version.
.SetAsync("Blablabla", "6QLE0LL7iw7tHPAwold31qUENt3lVTUZxDGqeXQFx38=");
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] blazor.webassembly.js:1:36074 Unhandled exception rendering component: 'Q' is an invalid end of a number. Expected a delimiter. Path: $ | LineNumber: 0 | BytePositionInLine: 1. blazor.webassembly.js:1:36074 System.Text.Json.JsonException: 'Q' is an invalid end of a number. Expected a delimiter. Path: $ | LineNumber: 0 | BytePositionInLine: 1. ---> System.Text.Json.JsonReaderException: 'Q' is an invalid end of a number. Expected a delimiter. LineNumber: 0 | BytePositionInLine: 1. blazor.webassembly.js:1:36074 at System.Text.Json.ThrowHelper.ThrowJsonReaderException (System.Text.Json.Utf8JsonReader& json, System.Text.Json.ExceptionResource resource, System.Byte nextByte, System.ReadOnlySpan
1[T] bytes) <0x2ab0460 + 0x00020> in :0 blazor.webassembly.js:1:36074
at System.Text.Json.Utf8JsonReader.TryGetNumber (System.ReadOnlySpan1[T] data, System.Int32& consumed) <0x2a154a0 + 0x00136> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.Utf8JsonReader.ReadFirstToken (System.Byte first) <0x28771f0 + 0x00160> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.Utf8JsonReader.ReadSingleSegment () <0x2876bb8 + 0x001fe> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.Utf8JsonReader.Read () <0x2876740 + 0x0000e> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.ReadCore (System.Text.Json.JsonSerializerOptions options, System.Text.Json.Utf8JsonReader& reader, System.Text.Json.ReadStack& readStack) <0x28760b0 + 0x0005e> in <filename unknown>:0 blazor.webassembly.js:1:36074 --- End of inner exception stack trace --- blazor.webassembly.js:1:36074 at System.Text.Json.ThrowHelper.ReThrowWithPath (System.Text.Json.ReadStack& readStack, System.Text.Json.JsonReaderException ex) <0x2b02e80 + 0x00108> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.ReadCore (System.Text.Json.JsonSerializerOptions options, System.Text.Json.Utf8JsonReader& reader, System.Text.Json.ReadStack& readStack) <0x28760b0 + 0x00292> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.ReadCore (System.Type returnType, System.Text.Json.JsonSerializerOptions options, System.Text.Json.Utf8JsonReader& reader) <0x286d0f8 + 0x0002e> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.Deserialize (System.String json, System.Type returnType, System.Text.Json.JsonSerializerOptions options) <0x286c090 + 0x0017a> in <filename unknown>:0 blazor.webassembly.js:1:36074 at System.Text.Json.JsonSerializer.Deserialize[TValue] (System.String json, System.Text.Json.JsonSerializerOptions options) <0x2a87938 + 0x0000c> in <filename unknown>:0 blazor.webassembly.js:1:36074 at Blazored.LocalStorage.LocalStorageService.GetItemAsync[T] (System.String key) <0x2aaf650 + 0x0018e> in <filename unknown>:0 blazor.webassembly.js:1:36074 at Blazored.LocalStorage.LocalStorageService.RaiseOnChangingAsync (System.String key, System.Object data) <0x2ab7bd0 + 0x000fc> in <filename unknown>:0 blazor.webassembly.js:1:36074 at Blazored.LocalStorage.LocalStorageService.SetItemAsync (System.String key, System.Object data) <0x2ab6bb8 + 0x000fe> in <filename unknown>:0
from localstorage.
What i see is that setitemasync is believing that i'm trying to save an int, instead a string.
from localstorage.
The problem comes from LocalStorageService.cs, Line 183, when RaiseOnChangingAsync
calls GetItemAsync<object>(key)
. Should it be the same T
and also GetItemAsync<string>(key)
so it's running in the else-clause?
EDIT: I thought about it, maybe a simple try-catch would be enough, when the T of GetItemAsync is object?
from localstorage.
The problem is that when RaiseOnChangingAsync
is called we don't know what T
should be. A developer could be overwriting a value with a certain type, and replacing it with a value of a different type.
I've added a new internal version of GetItemAsync
which doesn't have the additional check for T
not being a string
. This seems to have fixed it.
from localstorage.
Yep, removing this condition works for me too. The checks for JSON start and end should be enough imho.
from localstorage.
Related Issues (20)
- How to send facebook token(passport-facebook) from Frontend after I logged in?
- how inject in Code behind in program.cs HOT 5
- AddBlazoredLocalStorage() add public setter for options.JsonSerializerOptions HOT 2
- [Bug] LocalStorage crashes without throwing exception HOT 14
- [Bug] Impossible to make it work HOT 1
- [Bug] ASP.NET Core AggregateException on startup after injecting BlazorLocalStorage with dependency injection HOT 2
- [Bug] Performance Impact on Multiple SetItem Calls
- [Security] Consider updating Microsoft.AspNetCore.Components.Web dependency
- Net 8.0 iOS System.Text.Json.Serialization.JsonConverter System.ArgumentOutOfRangeException [Bug] HOT 1
- Unhandled exception rendering component: Please use dedicated worker for working with JavaScript interop. See https://aka.ms/dotnet-JS-interop-threads
- .Net 8 RenderMode.InteractiveServer CustomAuthenticationStateProvider[Bug] HOT 2
- Error in .NET 8 : Method not found HOT 3
- [Feature Request] Common Interface between ILocalStorageService and ISessionStorageService
- is it not working on net maui Hybrid? HOT 1
- [Bug] Lists of tuples are not being serialized correctly
- blazored.localstorage is missing NuGet package README file
- [Bug] Can't use local storage in a SSR HOT 1
- [Question] How can I use it in program.cs ? HOT 3
- Whether cookie operations can be added
- [Feature Request] An option to automatically add `location.pathname` to keys
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from localstorage.