Visual Studio 2015スキャフォールディングはUserManager<TUser>
を使用しており、ClaimsIdentity
の作成には使用できません。誰かがこれを行う方法の実例を持っていますか?ID 3にクレーム識別情報を作成
VS2015の足場は、エラーがスローされます。
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one
// defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
N.B:私はIdentyUser
と競合しないApplicationUser
にプロパティを追加しました。
足場はどんなエラーを投げますか?あなたが投稿したメソッドは、それが 'ClaimsIdentity'を返していることを示します – Nkosi
UserManagerにCreateIdentityAsyncまたはDefaultAuthenticationTypesの定義が含まれていません –
Ungaro
再現するにはVS2015 MVC 6テンプレートを使用して新しいASP.NET Webプロジェクトを作成します。 ApplicationUser.csのモデルでは、System.Security.ClaimsおよびMicosoft.AspNet.Identityへの参照を追加し、上のコードをApplicationUserクラスに挿入します。上記のコメントに記載されているエラーを参照してください。 – Ungaro