Logged in via Swaggger/API as well as the Angular App. But when try to create a entity in the DB, getting this exception.
at Abp.Authorization.AuthorizationHelper.Authorize(IEnumerable1 authorizeAttributes) at Abp.Authorization.AuthorizationHelper.CheckPermissions(MethodInfo methodInfo, Type type) at Abp.Authorization.AuthorizationHelper.Authorize(MethodInfo methodInfo, Type type) at Abp.Authorization.AuthorizationInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Auditing.AuditingInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Abp.Runtime.Validation.Interception.ValidationInterceptor.Intercept(IInvocation invocation) at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.Proxies.TripsAppServiceProxy.Create(CreateOrEditTripDto input) at App.Trips.TripsAppService.<CreateOrEdit>d__6.MoveNext() in D:\github\App\aspnet-core\src\App.Application\Trips\TripsAppService.cs:line 91 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at App.Trips.Importing.ImportTripsToExcelXlsJob.<CreateTripAsync>d__15.MoveNext() in D:\github\App\aspnet-core\src\App.Application\Trips\Importing\ImportTripsToExcelXlsJob.cs:line 135 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.<>c__DisplayClass15_0.<Run>b__0(Task t) at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at Nito.AsyncEx.AsyncContext.Run(Func
1 action)
at Abp.Threading.AsyncHelper.RunSync(Func1 action) at App.Trips.Importing.ImportTripsToExcelXlsJob.CreateTrips(ImportTripsFromExcelJobArgs args, List
1 trips) in D:\github\App\aspnet-core\src\App.Application\Trips\Importing\ImportTripsToExcelXlsJob.cs:line 89
2 Answer(s)
-
0
There is no session (and no user) in a background job.
Ideally, avoid using app service in background job in the first place.
// AsyncHelper.RunSync(() => _tripsAppService.CreateOrEdit(...)); AsyncHelper.RunSync(() => _tripsManager.CreateOrEdit(...));
Otherwise, you can pass
UserIdentifier
to your background job and then override current session values:using (AbpSession.Use(args.User.TenantId, args.User.UserId)) { AsyncHelper.RunSync(() => _tripsAppService.CreateOrEdit(...)); }
-
0
This issue is closed because of no recent activity. Please open a new issue if you are still having this problem.