Registering IIdentity for SignalR
Closed this issue · 1 comments
SirwanAfifi commented
Thanks a lot for adding this feature. It seems that it has some problems when using SignalR:
public class NotificationHub : Hub
{
private readonly IApplicationUserManager _userManager;
// other dependencies
public NotificationHub(IApplicationUserManager userManager, ....)
{
_userManager = userManager;
//,....
}
//....
}
Exception:
Failure while building 'Lambda: IIF((HttpContext.Current.User != null), IIF((HttpContext.Current != null), HttpContext.Current.User.Identity, null), null)', check the inner exception for details
1.) Lambda: IIF((HttpContext.Current.User != null), IIF((HttpContext.Current != null), HttpContext.Current.User.Identity, null), null)
2.) Instance of System.Security.Principal.IIdentity
3.) new ApplicationUserManager(*Default of IUserStore<ApplicationUser, Int32>*, *Default of IUnitOfWork*, *Default of IIdentity*, *Default of IApplicationRoleManager*, *Default of IDataProtectionProvider*, Lifecycle resolution of MyProject.Service.Entities.SmsService, Lifecycle resolution of MyProject.Service.Entities.EmailService){
Set IIdentityMessageService EmailService = Lifecycle resolution of MyProject.Service.Entities.EmailService
Set IIdentityMessageService SmsService = Lifecycle resolution of MyProject.Service.Entities.SmsService
}
4.) MyProject.Service.Entities.ApplicationUserManager
5.) Instance of MyProject.Service.Interfaces.IApplicationUserManager (MyProject.Service.Entities.ApplicationUserManager)
6.) new NotificationHub(*Default of IRequestService*, *Default of IResponseService*, *Default of IApplicationUserManager*)
7.) MyProject.Web.Hubs.NotificationHub
8.) Instance of MyProject.Web.Hubs.NotificationHub
9.) Container.GetInstance(MyProject.Web.Hubs.NotificationHub)
VahidN commented
Try
ioc.For<IIdentity>().Use(() => (HttpContext.Current != null && HttpContext.Current.User != null) ? HttpContext.Current.User.Identity : null);