Andrew Arnott 有一篇关于如何从 OpenId 提供者中提取属性交换扩展数据的帖子。这是代码片段:-
var fetch = openid.Response.GetExtension<FetchResponse>();
if (fetch != null)
{
IList<string> emailAddresses = fetch.GetAttribute
(WellKnownAttributes.Contact.Email).Values;
IList<string> fullNames = fetch.GetAttribute
(WellKnownAttributes.Name.FullName).Values;
string email = emailAddresses.Count > 0 ? emailAddresses[0] : null;
string fullName = fullNames.Count > 0 ? fullNames[0] : null;
}
当我尝试执行以下操作时...
fetch.GetAttribute(...)
我得到一个编译错误。基本上,那是不存在的。是这样做的唯一(阅读:正确)方法如下......
fetch.Attribue[WellKnownAttributes.Contact.Email].Values
干杯:)