8.2.1, Angular, .Net Core
Sometimes, when impersonating as a tenant user, an exception is thrown (...pZeroTemplate.Web.Core/Authentication/JwtBearer/AbpZeroTemplateJwtSecurityTokenHandler.cs
):
Log.txt:
ERROR 2020-02-28 14:19:06,679 [44 ] Mvc.ExceptionHandling.AbpExceptionFilter - A task was canceled.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
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.QueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase`3.FirstOrDefaultAsync(TPrimaryKey id)
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at CompanyName.ProjectName.Authorization.Users.UserManager.GetUserOrNullAsync(UserIdentifier userIdentifier) in D:\UserName\source\repos\CompanyName.ProjectName.Core\src\CompanyName.ProjectName.Core\Authorization\Users\UserManager.cs:line 84
at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation)
at CompanyName.ProjectName.Authorization.Users.UserManager.GetUserAsync(UserIdentifier userIdentifier) in D:\UserName\source\repos\CompanyName.ProjectName.Core\src\CompanyName.ProjectName.Core\Authorization\Users\UserManager.cs:line 95
at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task`1 task)
at Nito.AsyncEx.AsyncContext.<>c__DisplayClass16_0`1.<Run>b__0(Task`1 t)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task`1 task)
at Nito.AsyncEx.AsyncContext.Run[TResult](Func`1 action)
at Abp.Threading.AsyncHelper.RunSync[TResult](Func`1 func)
at CompanyName.ProjectName.Authorization.Users.UserManager.GetUser(UserIdentifier userIdentifier) in D:\UserName\source\repos\CompanyName.ProjectName.Core\src\CompanyName.ProjectName.Core\Authorization\Users\UserManager.cs:line 106
at CompanyName.ProjectName.Web.Controllers.TokenAuthController.LogOut() in D:\UserName\source\repos\CompanyName.ProjectName.Core\src\CompanyName.ProjectName.Web.Core\Controllers\TokenAuthController.cs:line 268
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>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>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Further information:
Can anybody confirm this behaviour?
I did also implement changes according to remove unused codes but it did not change the behaviour.
Microsoft will continue to support Basic Auth for SMTP in Exchange Online: End of support for Basic Authentication access to Exchange Online API’s for Office 365 customers But, for our company the problem still exists since we are Microsoft partner and therefor obligated to turn off Basic Auth for our services by the end of february 2020.
Microsoft is working on OAuth for IMAP in Exchange Online: IMAP auth in Office 365 using OAuth2
Abp.MailKit: DefaultMailKitSmtpBuilder
This might be useful as well:
My own question on SO: How do I connect to Exchange Online using OAuth 2.0 in MailKit?
I see, thanks @demirmusa!
I thought I could use the deleting event handler in order to avoid a foreign-key constraint when deleting entity of type A. But it doesn't work like that. I guess, I'll better be using a custom event handler instead of the deleting event handler.
8.0.0, Angular, .NET Core
I need to set a relation between two entities of type A and B to null before deleting entity of type A. I thought I could do that easily with predefined events but it turns out the deleting event handler does not get triggered (also, see [EntityDeletingEventData does not fire on deleting user #1460](https://github.com/aspnetzero/aspnet-zero-core/issues/1460)).
Right now, I call the deleting event handler manually using the event bus before deleting the entity itself:
public async Task DeleteAsync(int id)
{
await EventBus.TriggerAsync(new EntityDeletingEventData<A>(new A { Id = id }));
await _aRepository.DeleteAsync(id);
}
This works as expected but I guess it is not how it is supposed to be done!? Any ideas why the deleting event handler doesn't get triggered properly? Am i missunderstanding something?
I stumbled across this issue for another time just the day before yesterday. Again, I just cleaned and rebuilt the solution a couple of times and also had to restart Visual Studio / reopen the solution. Actually, I have no idea what causes this problem but I think you just have to be patient with the cleaning and rebuilding : /
Thanks to TenantManager
domain service I can add the following to my test-class constructor:
var tenantManager = Resolve<TenantManager>();
tenantManager.SetFeatureValue(GetCurrentTenant().Id, "FeatureName", "Value");
So, this actually seems to be the solution to my problem : )
~~But I don't know if this change will be persisted for longer than just for the test run. And I can't figure out where this information is stored ... Any ideas?~~
Edit Changes won't be persisted for longer than for the run of the test itself. So, this is the way to go : )
The Code for my app-services and tests really isn't anything special - just some simple gets, creates, edits and deletes - and as I wrote before: this stuff is working as expected as soon as I enable the according feature the permission depends on by default (defaultValue: true
). Before, my tests failed just because the DefaultTenant didn't have these features assigned and therefore didn't have the necessary permissions.
What I would like to know is, how do I assign a certain feature to a tenant in my tests (something similar to LoginAsDefaultTenantAdmin()
)? I guess, right now there is no simple way to do this. But maybe you guys have some ideas on how to do this? Also, I think it would be a good addition for ASPNETZERO as a product.
8.0.0, Angular, .NET Core
I stumbled accross the following error when trying to run tests I built for one of my app-services:
Required permissions are not granted. At least one of these permissions must be granted: PermissionName
Couldn't find an answer here.
After a couple of hours searching for a solution to this problem it began to dawn on me:
Permissions for this service are dependent on a feature that is not enabled by default (defaultValue: false
in AppFeatureProvider.cs
).
Enabling it by default solved the problem as expected.
Now I have the following question:
I don't want certain features to be enabled by default but still want to test the app-services - Is there a simple solution to this problem without having to manually change the defaulValue
for each feature?
~~7.3.1, Angular, .NET Framework~~ 8.1.0, Angular, .NET Core
We are using Microsoft Office 365 / Exchange Online and our ASPNETZERO-based application sends e-mails using an Office 365 account - all is working fine.
On the 13th of October in 2020 Microsoft will decomission Basic Authentication for Exchange Web Services for Office 365 (read: Upcoming changes to Exchange Web Services (EWS) API for Office 365).
So, we tested to see what this means for our ASPNETZERO-based application and turned off / blocked Basic Authentication for our Office 365 accounts temporarily. Result: Our application was no longer able to authenticate to send the test e-mail.
Are there any plans to implement OAuth for E-Mail?
It works!
I just cleaned and rebuilt (not just build; that didn't do anything it seems) the solution (multiple times), regenerated services-proxies and all is fine now.
I also implemented a simple change to Startup.cs
by @maliming (not sure if this is important to the problem):
Adjust the Authorization middleware order.