1
我正在使用ASP.NET Identity 2.0。我看到许多ASP.NET Identity这样的样本:Microsoft.Owin.Security.xyz OnAuthenticated不存储在数据库中
const string XmlSchemaString = "http://www.w3.org/2001/XMLSchema#string";
var facebookOptions = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions
{
AppId = ConfigurationManager.AppSettings.Get("FacebookAppId"),
AppSecret = ConfigurationManager.AppSettings.Get("FacebookAppSecret"),
Provider = new Microsoft.Owin.Security.Facebook.FacebookAuthenticationProvider()
{
OnAuthenticated = (context) =>
{
var claim = new System.Security.Claims.Claim("urn:facebook:access_token", context.AccessToken, XmlSchemaString, "Facebook");
foreach (var x in context.User)
{
string key = string.Format("urn:facebook:{0}", x.Key);
string value = x.Value.ToString();
claim.Properties.Add(key, value);
}
context.Identity.AddClaim(claim);
return Task.FromResult(0);
}
}
};
AddClaim看起来像只是将这些声明添加到内存中。不存储在数据库中。这是正常的吗?我的意思是,如果我想将这些声明存储到数据库中并读取它,我该怎么办?我很少看到有关此的任何代码示例。