私はASP.NET
EFエンドでコアIDを使用しています認証クッキーにユーザーに関連するデータを保存したいと思います。データをasp.netコアIDを持つクッキーに保存します
これは(appcontext
を格納するためのデータである)私はASP.NET 4.6
に行うために使用される方法です:
public static void IdentitySignin(AppContext appContext, string providerKey = null, bool isPersistent = false)
{
var claims = new List<Claim>();
// create *required* claims
claims.Add(new Claim(ClaimTypes.NameIdentifier, appContext.UserId.ToString()));
claims.Add(new Claim(ClaimTypes.Name, appContext.UserName));
// serialized AppUserState object
claims.Add(new Claim("appcontext" + EZA.Store.AppContext.Version, appContext.ToString()));
var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
// add to user here!
AuthenticationManager.SignIn(new AuthenticationProperties()
{
AllowRefresh = true,
IsPersistent = isPersistent,
ExpiresUtc = DateTime.UtcNow.AddDays(7),
}, identity);
}
今はEF
でASP.NET Identity
を使用していると私はいくつかのデータを格納するための方法を見つけることができませんクッキーに
わかりません-to-aspnet-identity)? –
あなたはそれを仲間に働かせましたか? – user3127109