if (Page.IsPostBack){ using (var openID = new OpenIDRelyingParty()) { var request = openID.CreateRequest(Request.Form["openID_IDentifIEr"]); var fetch = new FetchRequest(); fetch.Attributes.Add(new AttributeRequest(WellKNownAttributes.Contact.Email,true)); request.AddExtension(fetch); request.RedirecttoprovIDer(); }}else{ using (var openID = new OpenIDRelyingParty()) { var response = openID.GetResponse(); if (response != null) { switch (response.Status) { case AuthenticationStatus.Authenticated: var claimsResponse = response.GetExtension<FetchRequest>(); break; case AuthenticationStatus.Canceled: //this.loginCanceledLabel.Visible = true; break; case AuthenticationStatus.Setuprequired: //this.loginFailedLabel.Visible = true; break; // We don't need to handle Setuprequired because we're not setting // IAuthenticationRequest.Mode to immediate mode. ////case AuthenticationStatus.Setuprequired: //// break; } } }}
谁知道什么是错的?
解决方法 请尝试以下代码:switch (response.Status) { case AuthenticationStatus.Authenticated: var fetch = response.GetExtension<FetchResponse>(); string email = String.Empty; if (fetch != null) { email = fetch.GetAttributeValue(WellKNownAttributes.Contact.Email); } break; //...}总结
以上是内存溢出为你收集整理的c# – 使用DotNetOpenAuth从OpenID Provider获取电子邮件地址全部内容,希望文章能够帮你解决c# – 使用DotNetOpenAuth从OpenID Provider获取电子邮件地址所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)