我IUserService
的为空,不知道发生了什么。这是我的AccountController
:
private readonly ICustomMembershipProvider _membershipProvider;
public AccountController(ICustomMembershipProvider provider)
{
_membershipProvider = provider;
}
//other code omitted
我的CustomMembershipProvider
:
public class CustomMembershipProvider : MembershipProvider, ICustomMembershipProvider
{
private IUserService _userService;
public CustomMembershipProvider()
: this(DependencyResolver.Current.GetService<IUserService>())
{
}
public CustomMembershipProvider(IUserService userService)
{
_userService = userService;
}
//other code omitted
当我尝试注册用户并调用以下方法时,我_userService
的为空,这就是导致错误的原因,但不确定为什么会发生。
public override MembershipUser GetUser(string username, bool userIsOnline)
{
var tempUser = _userService.GetByName(username);
//other code omitted
所有其他依赖项都已成功解决