Posted on 17/02/2025 12:32:51
Logon and Logoff are very different in Dynamicweb 9 and Dynamicweb 10 as the latter utilizes Microsoft.AspNetCore.Authentication from asp.net core.
So you cannot do what you try as it belongs to the DW9 world.
I can see you do a logiin notification subscriber and as part of that also do the logoff. That is probably not going to work.
You can logoff the user like this using Microsoft.AspNetCore.Authentication and Microsoft.AspNetCore.Http namespaces:
var context = HttpContextAccessor.HttpContext;
if (context is null)
throw new InvalidOperationException($"{nameof(HttpContextAccessor.HttpContext)} is null");
await context.SignOutAsync("Dynamicweb.Extranet");
That requires that you are in the context of asp.net and can get hold of a HttpContextAccessor instance - that would be in some middleware - and your notification subscriber is probably not in that context.
Instead you might be able to redirect the user to /Admin/Public/ExtranetLogoff.aspx after you have done what you do - and that would logoff the user.
You can also explain what you are trying to do - there is probably another way.