The sequence does not contain an element.

I used Google Login with help DotNetOpenAuthand it worked fine, but all of a sudden I got an exception in

Exception Details: System.InvalidOperationException: Sequence contains no elements

Source Error:

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.

Stack trace:

[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

But sometimes this is normal. I do not understand what will happen for this. Please check the problem when I get an exception.

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();
+4
source share
2 answers

This error occurs due to the absence of an item in your list and an attempt to use a single one. check if the list is null before use or make sure that your list must have at least one element.

+1
source

- - Google (ASP.NET Google OpenId www.google.com/accounts, 302 ).

1 1. , Iand1 IIS, -, . -, . - Google, - WCF, URL- 1and1. , , WCF , - 1and1. - , Google .

, - 1and1, WCF, -, Google !

, .

+1

Source: https://habr.com/ru/post/1530184/


All Articles