Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Initializing & Using Custom User Store in asp.net Identity

$
0
0

Hi I am creating custom user store as:

public class UserStore<TKey> : IUserStore<User<TKey>>
{
  private DbConnection _connection;
  /// <summary>
  ///     Database connection for User 
  /// </summary>
  /// <value>The connection.</value>
  public DbConnection Connection {
	get { return _connection; }
	set {
		if ( value == null )
			throw new ArgumentNullException( _emsg_ConnectioIsRequired );
			_connection = value;
	}
	}  		
  public UserStore( DbConnection connection ) {
			Connection = connection;
		}

  #region IUserStore implementation
    //Implementation goes here
  #end region
}

Then in my account controller I need to instantiate this user store to which I am having problems. 

I have something like this:

namespace Web.Controllers  
{
    public class AccountController : Controller
    {
        public AccountController()
            : this(new UserManager<User<string>>(new UserStore<User<string>>())) 
        // above this throws error as user store does not contain a constructor that takes 0 arguments
        {
        }

        public AccountController(UserManager<User<string>> userManager)
        {
            UserManager = userManager;
        }

        public UserManager<User<string>> UserManager { get; private set; }

}

Could you please help me in.

Thanks


Viewing all articles
Browse latest Browse all 4737

Trending Articles