Comments (12)
Thanks @freedyang I have reproduced this problem
from aspnetboilerplate.
Does this work https://stackoverflow.com/a/66963611 ?
from aspnetboilerplate.
It works for AbpRedisCache, but not for AbpPerRequestRedisCache:
services.AddControllersWithViews(options =>
{
options.Filters.Add(new AbpAutoValidateAntiforgeryTokenAttribute());
options.AddAbpHtmlSanitizer();
})
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.Converters.Add(new CustomJsonConverterForType());
});
from aspnetboilerplate.
Could you replace DefaultRedisCacheSerializer
with the one in this PR and see if it works ? https://github.com/aspnetboilerplate/aspnetboilerplate/pull/6887/files
from aspnetboilerplate.
After replacing the default implementation service of DefaultRedisCacheSerializer, it still does not work:
ReplaceService:
Configuration.ReplaceService<IRedisCacheSerializer, DefaultRedisCacheSerializerExtensions>(DependencyLifeStyle.Transient);
DefaultRedisCacheSerializerExtensions:
public class DefaultRedisCacheSerializerExtensions : IRedisCacheSerializer, ITransientDependency
{
public virtual object Deserialize(RedisValue objbyte)
{
var serializerSettings = new JsonSerializerOptions();
serializerSettings.Converters.Insert(0, new Abp.Json.SystemTextJson.AbpDateTimeConverter());
var cacheData = AbpCacheData.Deserialize(objbyte);
return cacheData.Payload.FromJsonString(
Type.GetType(cacheData.Type, true, true),
serializerSettings);
}
public virtual RedisValue Serialize(object value, Type type)
{
var json = AbpCacheData.Serialize(value);
return JsonSerializer.Serialize(json, new JsonSerializerOptions
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
});
}
}
from aspnetboilerplate.
@freedyang I couldn't reproduce this problem on a new project, is it possible to share a reproduction project ?
Could oyu also try to change DefaultRedisCacheSerializerExtensions as shown below ?
public class DefaultRedisCacheSerializerExtensions : IRedisCacheSerializer, ITransientDependency
{
public virtual object Deserialize(RedisValue objbyte)
{
var serializerSettings = new JsonSerializerOptions();
serializerSettings.Converters.Insert(0, new Abp.Json.SystemTextJson.AbpDateTimeConverter());
serializerSettings.Converters.Add(new CustomJsonConverterForType());
var cacheData = AbpCacheData.Deserialize(objbyte);
return cacheData.Payload.FromJsonString(
Type.GetType(cacheData.Type, true, true),
serializerSettings);
}
public virtual RedisValue Serialize(object value, Type type)
{
var json = AbpCacheData.Serialize(value);
return JsonSerializer.Serialize(json, new JsonSerializerOptions
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
});
}
}
from aspnetboilerplate.
@ismcagdas This bug is not related to the DefaultRedisCacheSerializer, it cause by AbpCacheData.Serialize(value):
- Abp.Runtime.Caching.Redis.AbpRedisCache.Serialize(Object value, Type type)
- Abp.Runtime.Caching.Redis.DefaultRedisCacheSerializer.Serialize(Object value, Type type)
- Abp.Runtime.Caching.AbpCacheData.Serialize(Object obj, Boolean withAssemblyName)
- Abp.Json.JsonExtensions.ToJsonString(Object obj, Boolean camelCase, Boolean indented)
- System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
- Throw the System.NotSupportedException...
from aspnetboilerplate.
Is it possible to provide a reproduction project ?
from aspnetboilerplate.
ASP.NET Zero v13.1.0-rc.1, WebCoreModule: UseRedis & UsePerRequestRedisCache:
Configuration.Caching.UseRedis(options =>
{
options.ConnectionString = _appConfiguration["Abp:RedisCache:ConnectionString"];
options.DatabaseId = -1
},
usePerRequestRedisCache: true
);
from aspnetboilerplate.
Is the app failing when you run it or does this happen in a specific case ?
from aspnetboilerplate.
if set UsePerRequestRedisCache = true, then each time login, will throw above exceltion.
The app won't crash and can run normally.
from aspnetboilerplate.
If back to UseNewtonsoft, then everthing is ok, no exceptions thrown:
CoreModule:
JsonExtensions.UseNewtonsoft = true;
from aspnetboilerplate.
Related Issues (20)
- GetAllIncludingAsync is missing from the IRepository interface.
- Low efficiency of soft deletion HOT 3
- UnitOfWork and Async calls - Abp Version 7.0.0 HOT 10
- Clock.Provider not working in abp v9 HOT 6
- GetAll Readonly method to IRepository HOT 1
- There is no async implementation of the AbpHangfireAuthorizationFilter.
- Retrieval of permissions is only possible synchronously. HOT 1
- When changing the language to Arabic, the layout didn't change to RTL and is still as en lang. HOT 3
- Add missed GetDbContextAsync Extension
- Update NuGet packages to latest version
- Use GetAllAsync for asynchronous methods HOT 1
- Upgrade templates to 9.2
- [Vulnerability]Ignoring tenant filters can result in cross-tenant unauthorized authorization attacks HOT 1
- OrganizationUnit does not generate audit correctly HOT 1
- Error in login and register page HOT 3
- PermissionManager - GetAllPermissionsAsync: where conditions bug
- Interceptors not firing HOT 2
- MultiDbContext does not work with the Migrator project
- ABP v9.2.2 backend job caused the database connection to remain unreleased HOT 2
- Abp.AspNetCore 8.4.0 .Net 7 Detect vulnerabilities when scanning using Snyk HOT 8
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 aspnetboilerplate.