序列不包含元素

问题描述 投票:4回答:3

我已经使用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();
c# asp.net .net linq dotnetopenauth
3个回答
1
投票
我在1and1上托管。在1and1 IIS上运行的应用程序无法直接联系不在同一服务器上的网站。我一直都在使用他们提供的代理。我的Web应用程序同时需要Google和位于另一个1and1网址上的另一个WCF Web服务。突然,除非我删除了1and1代理,否则WCF服务突然停止工作。但是删除代理意味着无法与Google联系。

所以我放回了1and1代理,但修改了WCF绑定配置以绕过该代理,并且再次使用Google帐户进行身份验证!

希望这为您解决问题提供了线索。


1
投票

0
投票

ServiceContract

“接口的属性。它的工作原理如下

[ServiceContract] public interface IRESAdapterService { [return: XmlElement("GetCategoriesResponse")] [OperationContract(Action = "urn:GetCategories")] [XmlSerializerFormat(SupportFaults = true)] [FaultContract(typeof(RESAdapterServiceFault))] Task<CategoryResponse> GetCategoriesRequest(); }

© www.soinside.com 2019 - 2024. All rights reserved.