أنشطة "327992883@qq.com"

hi

You can try to get access token from HttpContext in 7.2.3

var httpContext = HttpContextAccessor?.HttpContext; 
if (httpContext == null) 
{ 
    return null; 
} 
 
return await httpContext.GetTokenAsync("access_token"); 

I use this method to get the token, but the result is null

  • ABP Framework version: v7.2.3
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server,) /
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:
  • This is my code. When I use await _hubContext.Clients.Users(stringUserIds).SendAsync(message.MessageType.ToString(), message); No messages received in blazor page
public async Task SendToUsersAsync<T>(T message) where T : SigalRMessage
 {
     try
     {
         if (!message.UserIds.HasItems())
             return;

         var stringUserIds = message.UserIds.Where(s => !s.IsNullOrEmpty()).Select(x => x.Value.ToString()).ToList();
         await _hubContext.Clients.Users(stringUserIds).SendAsync(message.MessageType.ToString(), message);
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "error");
     }
 }
protected override async Task OnInitializedAsync()
{
    SetTableOption();

    var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
    var user = authState.User;
    var claims = CurrentUser.GetAllClaims();
    var headers = new Dictionary<string, string>();
    foreach (var claim in claims)
    {
        if (!headers.Keys.Contains(claim.Type))
            headers.Add(claim.Type, claim.Value);
    }

    _userToken = user.FindFirstValue("access_token"); 

    var signalRUrl = "wss://localhost:44320".EnsureEndsWith('/') + Configuration["HubUrl"].TrimStart('/');

    HubConnection = new HubConnectionBuilder()
        .WithUrl(signalRUrl, options =>
        {
            options.Headers = headers;
            options.AccessTokenProvider = () => Task.FromResult(_userToken);
        }).WithAutomaticReconnect().Build();

    // 2. 定义客户端方法以接收服务器消息
    HubConnection.On<SigalRMessage<Dictionary<string, string>>>(SigalRMessageTypeEnum.OrderSyncSuccess.ToString(), async message =>
    {
        await JSRuntime.InvokeVoidAsync("console.log", $"收到sigalr消息:{message.ToJson()} {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
        StateHasChanged(); 
    });

    await HubConnection.StartAsync();
}

I looked at some sample code

 [Inject]
    protected IAbpAccessTokenProvider AccessTokenProvider { get; set; }

    [Inject]
    protected IOptions<ChatBlazorMauiBlazorOptions> ChatBlazorMauiBlazorOptions { get; set; }

    [Inject]
    protected IOptions<AbpRemoteServiceOptions> AbpRemoteServiceOptions { get; set; }

    protected async override Task SetChatHubConnectionAsync()
    {
        var accessToken = await AccessTokenProvider.GetTokenAsync();

        var signalrUrl = ChatBlazorMauiBlazorOptions.Value.SignalrUrl ?? AbpRemoteServiceOptions.Value.RemoteServices.Default.BaseUrl;

        HubConnection = new HubConnectionBuilder()
            .WithUrl(signalrUrl.EnsureEndsWith('/') + "signalr-hubs/chat", options =>
            {
                options.AccessTokenProvider = () => Task.FromResult(accessToken);
            })
            .Build();
    }

But IAbpAccessTokenProvider does not seem to exist in abp7.2.3 version

إجابة

Will it work if you comment app.UseErrorPage(); ?

It's normal, thank you.

إجابة

Could you share the full logs? (both local and deployed) thanks. server logs : 2024-04-01 15:32:49.553 +08:00 [WRN] ---------- RemoteServiceErrorInfo ---------- { "code": "Volo.Authorization:010001", "message": "Authorization failed! Given policy has not granted.", "details": null, "data": {}, "validationErrors": null } 2024-04-01 15:32:49.554 +08:00 [WRN] Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. Volo.Abp.Authorization.AbpAuthorizationException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. at Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.CheckAsync(IAuthorizationService authorizationService, AuthorizationPolicy policy) at Volo.Abp.Authorization.MethodInvocationAuthorizationService.CheckAsync(MethodInvocationAuthorizationContext context) at Volo.Abp.Authorization.AuthorizationInterceptor.AuthorizeAsync(IAbpMethodInvocation invocation) at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at lambda_method5145(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 2024-04-01 15:32:49.556 +08:00 [WRN] Code:Volo.Authorization:010001 2024-04-01 15:32:49.556 +08:00 [INF] AuthenticationScheme: Identity.Application was challenged. 2024-04-01 15:32:49.556 +08:00 [INF] Executed action PDT.Platform.Controllers.QuarantineRecords.QuarantineRecordController.GetListAsync (PDT.Platform.HttpApi) in 8.3655ms 2024-04-01 15:32:49.556 +08:00 [INF] Executed endpoint 'PDT.Platform.Controllers.QuarantineRecords.QuarantineRecordController.GetListAsync (PDT.Platform.HttpApi)' 2024-04-01 15:32:49.578 +08:00 [INF] Request finished HTTP/1.0 GET http://pdtapi.loda.net.cn/api/quarantine-records/backend/getlist application/json - - 302 0 - 35.3289ms 2024-04-01 15:32:49.593 +08:00 [INF] Request starting HTTP/1.0 GET http://pdtapi.loda.net.cn/Error?httpStatusCode=401 - - 2024-04-01 15:32:49.596 +08:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Controllers.ErrorController.Index (Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared)' 2024-04-01 15:32:49.596 +08:00 [INF] Route matched with {action = "Index", controller = "Error", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Microsoft.AspNetCore.Mvc.IActionResult] Index(Int32) on controller Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Controllers.ErrorController (Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared). 2024-04-01 15:32:49.597 +08:00 [INF] Executing ViewResult, running view ~/Views/Error/401.cshtml. 2024-04-01 15:32:49.598 +08:00 [WRN] The cookie 'XSRF-TOKEN' has set 'SameSite=None' and must also set 'Secure'. 2024-04-01 15:32:49.601 +08:00 [INF] Executed ViewResult - view ~/Views/Error/401.cshtml executed in 3.984ms.

<br> local logs: 2024-04-01 15:30:55.682 +08:00 [WRN] ---------- RemoteServiceErrorInfo ---------- { "code": "Volo.Authorization:010001", "message": "Authorization failed! Given policy has not granted.", "details": null, "data": {}, "validationErrors": null } 2024-04-01 15:30:55.682 +08:00 [WRN] Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. Volo.Abp.Authorization.AbpAuthorizationException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown. at Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.CheckAsync(IAuthorizationService authorizationService, AuthorizationPolicy policy) at Volo.Abp.Authorization.MethodInvocationAuthorizationService.CheckAsync(MethodInvocationAuthorizationContext context) at Volo.Abp.Authorization.AuthorizationInterceptor.AuthorizeAsync(IAbpMethodInvocation invocation) at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at lambda_method3659(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 2024-04-01 15:30:55.682 +08:00 [WRN] Code:Volo.Authorization:010001 2024-04-01 15:30:55.683 +08:00 [INF] AuthenticationScheme: Identity.Application was challenged. 2024-04-01 15:30:55.683 +08:00 [INF] Executed action PDT.Platform.Controllers.QuarantineRecords.QuarantineRecordController.GetListAsync (PDT.Platform.HttpApi) in 11.8705ms 2024-04-01 15:30:55.683 +08:00 [INF] Executed endpoint 'PDT.Platform.Controllers.QuarantineRecords.QuarantineRecordController.GetListAsync (PDT.Platform.HttpApi)' 2024-04-01 15:30:55.727 +08:00 [DBG] Added 0 entity changes to the current audit log 2024-04-01 15:30:55.729 +08:00 [DBG] Added 0 entity changes to the current audit log 2024-04-01 15:30:55.731 +08:00 [INF] Request finished HTTP/1.1 GET https://localhost:44312/api/quarantine-records/backend/getlist application/json 328 - 401 - - 68.1606ms 2024-04-01 15:31:04.981 +08:00 [DBG] Executing HealthCheck collector HostedService. 2024-04-01 15:31:04.982 +08:00 [INF] Start processing HTTP request GET https://localhost:44312/health-status 2024-04-01 15:31:04.982 +08:00 [INF] Sending HTTP request GET https://localhost:44312/health-status

إجابة

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info:

  • ABP Framework version: v7.2.3
    • Database System: EF Core
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:API Unauthorized 401 Redirection Error,My goal is not to redirect, just return to the normal HTTP state,I added the request header X-Requested With: XMLHttpRequest, which works normally during local debugging, but when deployed to the server using nginx reverse proxy, it has no effect. Still redirect the login page.

Hi,you can try running the project and stay on the testing book list. After an hour of token expiration, clicking the query button again will cause the page to flicker continuously until the program crashes.

hi

The page will keep flashing. AbpComponentsBase is not used, but a custom base class, in which the exception handling code:

Please share a test template project with your custom code. liming.ma@volosoft.com

Thanks.

Already send for your email

  • ABP Framework version: v7.2.3

  • UI Type: Blazor Server

  • Database System: EF Core (SQL Server)

  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

  • Exception message and full stack trace:2024-02-05 16:25:32.378 +08:00 [ERR] Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.IdentityUserClientProxy.GetAssignableRolesAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.UserManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.378 +08:00 [ERR] 执行异常处理逻辑,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.378 +08:00 [ERR] 执行异常处理401过期,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.378 +08:00 [WRN] Unhandled exception rendering component: Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.IdentityUserClientProxy.GetAssignableRolesAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.UserManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.378 +08:00 [ERR] Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.OrganizationUnitClientProxy.GetListAllAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.OrganizationUnitsManagement.GetOrganizationUnitsAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.OrganizationUnitsManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.379 +08:00 [ERR] 执行异常处理逻辑,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.379 +08:00 [ERR] 执行异常处理401过期,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.379 +08:00 [WRN] Unhandled exception rendering component: Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.OrganizationUnitClientProxy.GetListAllAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.OrganizationUnitsManagement.GetOrganizationUnitsAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.OrganizationUnitsManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.380 +08:00 [ERR] Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.IdentityUserClientProxy.GetExternalLoginProvidersAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.Components.IdentityUserImportDropdownComponent.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.380 +08:00 [ERR] 执行异常处理逻辑,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.380 +08:00 [ERR] 执行异常处理401过期,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.380 +08:00 [WRN] Unhandled exception rendering component: Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.IdentityUserClientProxy.GetExternalLoginProvidersAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.Components.IdentityUserImportDropdownComponent.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.380 +08:00 [INF] Received HTTP response headers after 64.4974ms - 401 2024-02-05 16:25:32.380 +08:00 [INF] End processing HTTP request after 64.705ms - 401 2024-02-05 16:25:32.380 +08:00 [ERR] Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Saas.Host.ClientProxies.EditionClientProxy.GetListAsync(GetEditionsInput input) at Volo.Saas.Host.Blazor.Pages.Saas.Host.TenantManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.380 +08:00 [ERR] 执行异常处理逻辑,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.380 +08:00 [ERR] 执行异常处理401过期,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.380 +08:00 [WRN] Unhandled exception rendering component: Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Saas.Host.ClientProxies.EditionClientProxy.GetListAsync(GetEditionsInput input) at Volo.Saas.Host.Blazor.Pages.Saas.Host.TenantManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.381 +08:00 [ERR] Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.OrganizationUnitClientProxy.GetListAllAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.OrganizationUnitsManagement.GetOrganizationUnitsAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.OrganizationUnitsManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.381 +08:00 [ERR] 执行异常处理逻辑,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.381 +08:00 [ERR] 执行异常处理401过期,HttpStatusCode--401,Message--Unauthorized 2024-02-05 16:25:32.381 +08:00 [WRN] Unhandled exception rendering component: Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.OrganizationUnitClientProxy.GetListAllAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.OrganizationUnitsManagement.GetOrganizationUnitsAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.OrganizationUnitsManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.382 +08:00 [ERR] Unauthorized Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.Abp.Identity.IdentityUserClientProxy.GetAssignableRolesAsync() at Volo.Abp.Identity.Pro.Blazor.Pages.Identity.UserManagement.OnInitializedAsync() at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) 2024-02-05 16:25:32.382 +08:00 [ERR] 执行异常处理逻辑,HttpStatusCode--401,Message--Unauthorized

  • Steps to reproduce the issue:After staying on the page for a few hours, click the query button of the page again. The status is 401 but it will not jump to the login page. The page will keep flashing. AbpComponentsBase is not used, but a custom base class, in which the exception handling code:

  • ` protected override async Task OnErrorAsync(Exception exception) { if (IsDisposed) return;

           Logger.LogError(new EventId(0, "Global Exception"), exception: exception, message: exception.Message);
           if (exception is AbpRemoteCallException)
           {
               var ex = exception as AbpRemoteCallException;
               Logger.LogError($"Execute exception handling logic, HttpStatusCode--{ex.HttpStatusCode},Message--{ex.Message}");
    
               //401 error returns to the original exception handling mechanism and allows the front desk to jump
               if (ex.HttpStatusCode == (int)HttpStatusCode.Unauthorized)
               {
                   Logger.LogError($"Execution exception handling 401 expired, HttpStatusCode--{ex.HttpStatusCode},Message--{ex.Message}");
                   await base.OnErrorAsync(exception);
                   return;
               }
    
               await UiMessageService.Info(ex.Error.Message, ex.Error.Code);
               return;
           }
    
           //await base.OnErrorAsync(exception);
           if (exception is UserFriendlyException)
           {
               var ex = exception as UserFriendlyException;
               await UiMessageService.Info(ex.Message);
               return;
           }
    
           if (exception is BusinessException)
           {
               var ex = exception as BusinessException;
               await UiMessageService.Warn(ex.Message, ex.Code);
               return;
           }
           await UiMessageService.Error(exception.Message);
       }`
    

hi

Yes.

https://docs.abp.io/en/commercial/latest/startup-templates/microservice/interservice-communication

But I am not using microservice template,I use the multi-module nuget management mode

عرض 1 الي 10 من 43 إدخالات
Made with ❤️ on ABP v8.2.0-preview Updated on مارس 25, 2024, 15:11