我已經使用DotNetOpenAuth
做了谷歌登錄,它工作正常,但所有的突然我漸漸對序列不包含任何元素
Exception Details: System.InvalidOperationException: Sequence contains no elements
源錯誤異常:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
堆棧跟蹤:
[InvalidOperationException: Sequence contains no elements]
System.Linq.Enumerable.First(IEnumerable`1 source) +269
DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) +250
[ProtocolException: No OpenID endpoint found.]
DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) +296
OpenIDGoogleLogin.Page_Load(Object sender, EventArgs e) +4626
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
但有些時候它工作正常。我不明白這是什麼問題。請檢查我收到異常的問題。
string discoveryUri = "https://www.google.com/accounts/o8/id";
OpenIdRelyingParty openid = new OpenIdRelyingParty();
string queryString = "";
var b = new UriBuilder(Request.Url) { Query = queryString };
var req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri);
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.Last);
req.AddExtension(fetchRequest);
req.RedirectToProvider();
您應該顯示產生堆棧跟蹤的代碼,即'OpenIDGoogleLogin.Page_Load' – CodingIntrigue
已更新我的問題中的代碼。請看看它。 –
你找到了解決辦法嗎? – samirprogrammer