Activities of "liangshiwei"

Hi,

It is already included in the headers.

Can you share the HTTP response detail (include header and body)?

Try

public static class RefreshRolesMiddlewareExtension
{
    public static IApplicationBuilder UseRefreshRolesMiddleware(this IApplicationBuilder app)
    {
        return app.Use(async (ctx, next) =>
        {
            var currentUser = ctx.RequestServices.GetRequiredService<ICurrentUser>();

            if (!currentUser.IsAuthenticated)
            {
                await next();
                return;
            }

            var userManager = ctx.RequestServices.GetRequiredService<IdentityUserManager>();

            var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService<ICurrentPrincipalAccessor>();
            var user = await userManager.GetByIdAsync(currentUser.GetId());
            var roles= await userManager.GetRolesAsync(user);
            var claims = currentPrincipalAccessor.Principal.Claims.ToList();

            claims.RemoveAll(x => x.Type == AbpClaimTypes.Role);
            claims.AddRange(roles.Select(x=> new Claim(AbpClaimTypes.Role, x)));

            using (currentPrincipalAccessor.Change(claims))
            {
                await next();
            }
        });
    }
}

Hi,

I have reproduced the problem, thank you, we will fix it. see https://github.com/abpframework/abp/pull/11006

PS: your ticket refunded.

For now, you can try:

[ExposeServices(
    typeof(ICachedApplicationConfigurationClient),
    typeof(IAsyncInitialize)
)]
public class MyMvcCachedApplicationConfigurationClient : ICachedApplicationConfigurationClient, ITransientDependency
{
    protected IHttpContextAccessor HttpContextAccessor { get; }
    protected AbpApplicationConfigurationClientProxy ApplicationConfigurationAppService { get; }
    protected ICurrentUser CurrentUser { get; }
    protected IDistributedCache<ApplicationConfigurationDto> Cache { get; }

    public MyMvcCachedApplicationConfigurationClient(
        IDistributedCache<ApplicationConfigurationDto> cache,
        AbpApplicationConfigurationClientProxy applicationConfigurationAppService,
        ICurrentUser currentUser,
        IHttpContextAccessor httpContextAccessor)
    {
        ApplicationConfigurationAppService = applicationConfigurationAppService;
        CurrentUser = currentUser;
        HttpContextAccessor = httpContextAccessor;
        Cache = cache;
    }

    public async Task InitializeAsync()
    {
        await GetAsync();
    }

    public async Task<ApplicationConfigurationDto> GetAsync()
    {
        var cacheKey = CreateCacheKey();
        var httpContext = HttpContextAccessor?.HttpContext;

        if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration)
        {
            return configuration;
        }


        configuration = await Cache.GetOrAddAsync(
            cacheKey,
            async () => await ApplicationConfigurationAppService.GetAsync(),
            () => new DistributedCacheEntryOptions
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300) //TODO: Should be configurable.
            }
        );

        if (httpContext != null)
        {
            httpContext.Items[cacheKey] = configuration;
        }

        return configuration;
    }

    public ApplicationConfigurationDto Get()
    {
        var cacheKey = CreateCacheKey();
        var httpContext = HttpContextAccessor?.HttpContext;

        if (httpContext != null && httpContext.Items[cacheKey] is ApplicationConfigurationDto configuration)
        {
            return configuration;
        }

        return AsyncHelper.RunSync(GetAsync);
    }

    protected virtual string CreateCacheKey()
    {
        var userKey = CurrentUser.Id?.ToString("N") ?? "Anonymous";
        return $"ApplicationConfiguration_{userKey}_{CultureInfo.CurrentUICulture.Name}";
    }
}

Hi,

Yes, IList<IFormFile> and IList<IRemoteStreamContent> both work.

Is there any benefit for me using IList<IRemoteStreamContent> here?

IRemoteStreamContent work with dynamic/static proxy system.

Hi,

The point is ID property, you need to change the API parameter name

Hi,

Thanks for the demo, I will check it.

Hi,

The middleware is just an example, you need to change the code according to your needs.

For your case, you need to replace the AbpClaimTypes.Role claim.

Hi,

I will check it , thanks.

Hi,

I have to try testing with a new startup template, but can't reproduce the problem, can you provide full steps? thanks.

Showing 5371 to 5380 of 6693 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 17, 2025, 07:08
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.