我已经使用DotNetOpenAuth
进行了Google登录,但工作正常,但是突然间我在[]上遇到了异常
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();
所以我放回了1and1代理,但修改了WCF绑定配置以绕过该代理,并且再次使用Google帐户进行身份验证!
希望这为您解决问题提供了线索。
ServiceContract
“接口的属性。它的工作原理如下
[ServiceContract] public interface IRESAdapterService { [return: XmlElement("GetCategoriesResponse")] [OperationContract(Action = "urn:GetCategories")] [XmlSerializerFormat(SupportFaults = true)] [FaultContract(typeof(RESAdapterServiceFault))] Task<CategoryResponse> GetCategoriesRequest(); }