私はカスタムMembershipProviderを作成する必要があり、潜在的なユーザーにログインするためにこのようなことをする必要がないのは非常に興味があります。私は、カスタムのMembershipProviderを作成した場合、私はasp.netメンバーシップ・テーブルを使用していないので、カスタムメンバーシッププロバイダを使用しないASP.NET MVCログインコントローラメソッド?
[HttpPost]
public ActionResult Login(string username, string password)
{
UserUnitOfWork unitOfWork = new UserUnitOfWork();
User user = unitOfWork.UserRepository.GetByUsername(username);
if (user != null)
{
SaltedHashHelper saltHelper = new SaltedHashHelper();
if (saltHelper.VerifyHashString(username, user.Password, user.Salt))
FormsAuthentication.SetAuthCookie(user.Username, false);
}
else
{
// User cannot be verified.
}
return View();
}
その後、私は、カスタムたMembershipUserを作成する必要があります。私はあなたがaspnetメンバーシップテーブルを使用していないときに頭痛の多くであるように感じる。たぶん私は間違っています。
誰も私の上記のアプローチに間違っていますか?私は興味がある。
誰がカスタムメンバーシッププロバイダを作成しなければならないと言ったのですか? –
私はちょうど "あなたが"私がオンラインで見たことのすべてからそれを行うべきであるという印象を得ました。 – Dietpixel
組み込みプロバイダーは使用しないでください。ここに答えがあります:http://stackoverflow.com/questions/1385042/asp-net-mvc-forms-authentication-authorize-attribute-simple-roles –