Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Internal error while accessing users page #12179


User avatar
0
alramz created

Hello,

I am facing an issue while accessing the users page in my asp.net zero application. It throws an internal error every time as shown below: While the browser logs display an error while calling the GetUsers API:

I'm unsure as to why this is occurring, any help is appreciated.


7 Answer(s)
  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @alramz,

    This page works correctly in the dev branch. Could you share the logs about the error? The logs are located in *.Mvc\App_Data\Logs

  • User Avatar
    0
    alramz created

    Hi @m.aliozkaya,

    Please find below the logs generated:

    DEBUG 2024-10-04 09:54:52,146 [31 ] Abp.AspNetCore.SignalR.Hubs.AbpCommonHub - A client is registered: vxEmIxuLt6I8zJa6MuqeIg WARN 2024-10-04 09:54:52,191 [44 ] EntityFrameworkCore.Database.Transaction - Savepoints are disabled because Multiple Active Result Sets (MARS) is enabled. If 'SaveChanges' fails, then the transaction cannot be automatically rolled back to a known clean state. Instead, the transaction should be rolled back by the application before retrying 'SaveChanges'. See https://go.microsoft.com/fwlink/?linkid=2149338 for more information and examples. To identify the code which triggers this warning, call 'ConfigureWarnings(w => w.Throw(SqlServerEventId.SavepointsDisabledBecauseOfMARS))'. INFO 2024-10-04 09:54:52,238 [46 ] Microsoft.AspNetCore.Hosting.Diagnostics - Request starting HTTP/1.1 GET https://localhost:44302/signalr-chat?id=Nx6eFZXFvleunmWY5P_LVg - - - INFO 2024-10-04 09:54:52,329 [20 ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. INFO 2024-10-04 09:54:52,342 [20 ] c.Infrastructure.ControllerActionInvoker - Executed action AlRamzPortal.Notifications.NotificationAppService.ShouldUserUpdateApp (AlRamzPortal.Application) in 222.4097ms INFO 2024-10-04 09:54:52,344 [20 ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'AlRamzPortal.Notifications.NotificationAppService.ShouldUserUpdateApp (AlRamzPortal.Application)' INFO 2024-10-04 09:54:52,345 [20 ] Microsoft.AspNetCore.Hosting.Diagnostics - Request finished HTTP/2 POST https://localhost:44302/api/services/app/Notification/ShouldUserUpdateApp - 200 - application/json;+charset=utf-8 448.5083ms INFO 2024-10-04 09:54:52,440 [46 ] ft.AspNetCore.Routing.EndpointMiddleware - Executing endpoint '/signalr-chat' DEBUG 2024-10-04 09:54:52,488 [47 ] AlRamzPortal.Web.Chat.SignalR.ChatHub - A client is connected: {"ConnectionId":"EaW642rpQzbdT-59Fvuiqg","IpAddress":"127.0.0.1","TenantId":1,"UserId":2,"ConnectTime":"2024-10-04T09:54:52.4884714+04:00","Properties":{}} INFO 2024-10-04 09:54:52,490 [48 ] Microsoft.AspNetCore.Hosting.Diagnostics - Request starting HTTP/2 GET https://localhost:44302/api/services/app/Chat/GetUserChatFriendsWithSettings - application/json - DEBUG 2024-10-04 09:54:52,528 [44 ] AlRamzPortal.Web.Chat.SignalR.ChatHub - A client is registered: EaW642rpQzbdT-59Fvuiqg INFO 2024-10-04 09:54:52,552 [46 ] ft.AspNetCore.Routing.EndpointMiddleware - Executing endpoint 'AlRamzPortal.Chat.ChatAppService.GetUserChatFriendsWithSettings (AlRamzPortal.Application)' INFO 2024-10-04 09:54:52,553 [46 ] c.Infrastructure.ControllerActionInvoker - Route matched with {area = "app", action = "GetUserChatFriendsWithSettings", controller = "Chat"}. Executing controller action with signature System.Threading.Tasks.Task1[AlRamzPortal.Chat.Dto.GetUserChatFriendsWithSettingsOutput] GetUserChatFriendsWithSettings() on controller AlRamzPortal.Chat.ChatAppService (AlRamzPortal.Application). INFO 2024-10-04 09:54:52,557 [46 ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. INFO 2024-10-04 09:54:52,559 [46 ] c.Infrastructure.ControllerActionInvoker - Executed action AlRamzPortal.Chat.ChatAppService.GetUserChatFriendsWithSettings (AlRamzPortal.Application) in 6.0811ms INFO 2024-10-04 09:54:52,559 [46 ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'AlRamzPortal.Chat.ChatAppService.GetUserChatFriendsWithSettings (AlRamzPortal.Application)' INFO 2024-10-04 09:54:52,559 [46 ] Microsoft.AspNetCore.Hosting.Diagnostics - Request finished HTTP/2 GET https://localhost:44302/api/services/app/Chat/GetUserChatFriendsWithSettings - 200 - application/json;+charset=utf-8 68.6388ms WARN 2024-10-04 09:54:52,581 [44 ] EntityFrameworkCore.Database.Transaction - Savepoints are disabled because Multiple Active Result Sets (MARS) is enabled. If 'SaveChanges' fails, then the transaction cannot be automatically rolled back to a known clean state. Instead, the transaction should be rolled back by the application before retrying 'SaveChanges'. See https://go.microsoft.com/fwlink/?linkid=2149338 for more information and examples. To identify the code which triggers this warning, call 'ConfigureWarnings(w => w.Throw(SqlServerEventId.SavepointsDisabledBecauseOfMARS))'. INFO 2024-10-04 09:54:52,589 [47 ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. INFO 2024-10-04 09:54:52,591 [47 ] c.Infrastructure.ControllerActionInvoker - Executed action AlRamzPortal.DynamicEntityProperties.DynamicEntityPropertyAppService.GetAllEntitiesHasDynamicProperty (AlRamzPortal.Application) in 731.7857ms INFO 2024-10-04 09:54:52,591 [47 ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'AlRamzPortal.DynamicEntityProperties.DynamicEntityPropertyAppService.GetAllEntitiesHasDynamicProperty (AlRamzPortal.Application)' INFO 2024-10-04 09:54:52,592 [47 ] Microsoft.AspNetCore.Hosting.Diagnostics - Request finished HTTP/2 GET https://localhost:44302/api/services/app/DynamicEntityProperty/GetAllEntitiesHasDynamicProperty - 200 - application/json;+charset=utf-8 822.7987ms ERROR 2024-10-04 09:54:53,396 [44 ] oft.EntityFrameworkCore.Database.Command - Failed executing DbCommand (645ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean), @__ef_filter__CurrentTenantId_1='?' (DbType = Int32), @__userIds_0='?' (Size = 4000)], CommandType='Text', CommandTimeout='30'] SELECT [a].[Id], [a].[CreationTime], [a].[CreatorUserId], [a].[RoleId], [a].[TenantId], [a].[UserId] FROM [AbpUserRoles] AS [a] WHERE (@__ef_filter__p_0 = CAST(1 AS bit) OR [a].[TenantId] = @__ef_filter__CurrentTenantId_1) AND [a].[UserId] IN ( SELECT [u].[value] FROM OPENJSON(@__userIds_0) WITH ([value] bigint '$') AS [u] ) ERROR 2024-10-04 09:54:53,789 [44 ] Microsoft.EntityFrameworkCore.Query - An exception occurred while iterating over the results of a query for context type 'AlRamzPortal.EntityFrameworkCore.AlRamzPortalDbContext'. Microsoft.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'WITH'. Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() ClientConnectionId:6f96ed7b-254e-40d6-aba0-d5212a56f19d Error Number:156,State:1,Class:15 Microsoft.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'WITH'. Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() ClientConnectionId:6f96ed7b-254e-40d6-aba0-d5212a56f19d Error Number:156,State:1,Class:15 WARN 2024-10-04 09:54:54,589 [44 ] EntityFrameworkCore.Database.Transaction - Savepoints are disabled because Multiple Active Result Sets (MARS) is enabled. If 'SaveChanges' fails, then the transaction cannot be automatically rolled back to a known clean state. Instead, the transaction should be rolled back by the application before retrying 'SaveChanges'. See https://go.microsoft.com/fwlink/?linkid=2149338 for more information and examples. To identify the code which triggers this warning, call 'ConfigureWarnings(w => w.Throw(SqlServerEventId.SavepointsDisabledBecauseOfMARS))'. ERROR 2024-10-04 09:54:54,734 [48 ] Mvc.ExceptionHandling.AbpExceptionFilter - Incorrect syntax near the keyword 'WITH'. Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. Microsoft.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'WITH'. Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location --- at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func4 operation, Func4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.MoveNextAsync() at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable1 source, CancellationToken cancellationToken) at AlRamzPortal.Authorization.Users.UserAppService.FillRoleNames(IReadOnlyCollection1 userListDtos) in C:\Users\mtariq\source\repos\Portal\src\AlRamzPortal.Application\Authorization\Users\UserAppService.cs:line 412 at AlRamzPortal.Authorization.Users.UserAppService.GetUsers(GetUsersInput input) in C:\Users\mtariq\source\repos\Portal\src\AlRamzPortal.Application\Authorization\Users\UserAppService.cs:line 121 at lambda_method2658(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.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.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.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) ClientConnectionId:6f96ed7b-254e-40d6-aba0-d5212a56f19d Error Number:156,State:1,Class:15 INFO 2024-10-04 09:54:54,741 [48 ] .Mvc.Infrastructure.ObjectResultExecutor - Executing ObjectResult, writing value of type 'Abp.Web.Models.AjaxResponse'. INFO 2024-10-04 09:54:54,743 [48 ] c.Infrastructure.ControllerActionInvoker - Executed action AlRamzPortal.Authorization.Users.UserAppService.GetUsers (AlRamzPortal.Application) in 2882.9018ms INFO 2024-10-04 09:54:54,743 [48 ] ft.AspNetCore.Routing.EndpointMiddleware - Executed endpoint 'AlRamzPortal.Authorization.Users.UserAppService.GetUsers (AlRamzPortal.Application)' INFO 2024-10-04 09:54:54,743 [48 ] Microsoft.AspNetCore.Hosting.Diagnostics - Request finished HTTP/2 POST https://localhost:44302/api/services/app/User/GetUsers - 500 - application/json;+charset=utf-8 2964.0545ms

  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi alramz

    Example: Incorrect:

    SELECT * FROM Users
    WITH UserCTE AS (SELECT * FROM Users WHERE IsActive = 1)
    

    Correct:

    SELECT * FROM Users;
    WITH UserCTE AS (SELECT * FROM Users WHERE IsActive = 1)
    

    In SQL Server, when using a WITH statement (like in Common Table Expressions - CTE), the previous query must be terminated with a semicolon (;).

    If the problem persists after you make this change, can you share with us the content of the FillRoleNames method in the UserAppService?

  • User Avatar
    0
    alramz created

    Hi oguzhanagir,

    Could you please clarify where these SQL statements can be found? as we haven't changed any of the relevant code for this?

    Thank you,

  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi alramz

    Can you share the contents of the FillRoleNames method within the UserAppService class with us? Have you made any changes to it? If you haven't made any changes here, we will need more information to reproduce the issue. You can send your project to the following email address [email protected].

  • User Avatar
    0
    alramz created

    Hi oguzhanagir,

    Please find below the unchanged FillRoleNames method: private async Task FillRoleNames(IReadOnlyCollection<UserListDto> userListDtos) { /* This method is optimized to fill role names to given list. */ var userIds = userListDtos.Select(u => u.Id);

    var userRoles = await _userRoleRepository.GetAll()
        .Where(userRole => userIds.Contains(userRole.UserId))
        .Select(userRole => userRole).ToListAsync();
    
    var distinctRoleIds = userRoles.Select(userRole => userRole.RoleId).Distinct();
    
    foreach (var user in userListDtos)
    {
        var rolesOfUser = userRoles.Where(userRole => userRole.UserId == user.Id).ToList();
        user.Roles = ObjectMapper.Map&lt;List&lt;UserListRoleDto&gt;>(rolesOfUser);
    }
    
    var roleNames = new Dictionary&lt;int, string&gt;();
    foreach (var roleId in distinctRoleIds)
    {
        var role = await _roleManager.FindByIdAsync(roleId.ToString());
        if (role != null)
        {
            roleNames[roleId] = role.DisplayName;
        }
    }
    
    foreach (var userListDto in userListDtos)
    {
        foreach (var userListRoleDto in userListDto.Roles)
        {
            if (roleNames.ContainsKey(userListRoleDto.RoleId))
            {
                userListRoleDto.RoleName = roleNames[userListRoleDto.RoleId];
            }
        }
    
        userListDto.Roles = userListDto.Roles.Where(r => r.RoleName != null).OrderBy(r => r.RoleName).ToList();
    }
    

    }

  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi alramz

    Can you share your project with us to reproduce the problem? Email Address: [email protected]