I am using Azure B2C for authentication on Client Side. When I am trying to invoke the Send Notification it is not sending notification.
public async Task SendNotifications(IEnumerable<NotificationServiceModel> notifications)
{
foreach (NotificationServiceModel notification in notifications)
{
string userId= httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
await hubContext.Clients.User(userId).SendAsync(ReceiveNotification, notification);
}
}
I am using Azure b2c Authentication with claimType Name which contains UserId
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(
options =>
{
Configuration.Bind("AzureAdB2C", options);
options.TokenValidationParameters.NameClaimType = "name";
},
options =>
{
Configuration.Bind("AzureAdB2C", options);
});
here is Hub Mapping
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<NotificationsHub>("/api/notifications");
endpoints.MapHub<OutlookHub>("/api/outlook");
endpoints.MapHub<EventsHub>("/api/live/events");
endpoints.MapControllerRoute(
"default",
"{controller}/{action=Index}/{id?}");
});