メンバーシップがコードで照合するApplicationNameを設定できます。
私は、一連の他のアプリケーションのすべてを管理する管理アプリケーションを持っています。私はそのアプリケーションのユーザーが他のすべてのアプリケーションにログインできるようにしたいので、デフォルトのアプリケーションでログインが失敗した場合は、「管理」アプリケーションを確認します。これは、私がログイン用に持っているものです。 "Membership.ApplicationName =" Administration ";"という行に注意してください。
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
Membership.ApplicationName = "Administration";
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && retu rnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
私が理解する限り、SQLメンバーシップ・プロバイダは複数のアプリケーションを使用できます。実際には、「aspnet_applications」という表があり、残りのスキーマがリンクされているアプリケーションのID、名前、および説明が格納されています。 – aleafonso
@aleafonso - 確かに、あなたが正しいです、私はちょうどあなたの答えの別の選択肢を提供することによっていくつかの光を陰にしたい。あなたの答えに+1。 – TheBoyan
@BojanSkrchevski - ありがとう、カスタムプロバイダが私たちが必要とするかもしれない、あなたのブログの記事を介して読んで、非常に便利だったかもしれません。 –