我创建了一个基于 ASP.NET MVC 4 Web 应用程序的站点。我按照 AuthConfig.cs 中的说明为 Twitter、Facebook 和 Google 启用了 OpenAuth 登录提供程序。
当站点在我的本地计算机上从 IIS Express 上的 Visual Studio 调试时,这可以正常工作。但是,当我将站点复制到另一台机器上时,整个站点都运行良好,除了使用开放式身份验证的任何站点。
在这台机器上,我可以使用浏览器访问 twitter、facebook 和 google。
当我尝试使用我的网站登录时,我得到:对于 Google:“序列不包含元素”,堆栈跟踪指向
[InvalidOperationException:序列不包含元素] System.Linq.Enumerable.First(IEnumerable`1 source) +514 DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) +106
[ProtocolException:未找到 OpenID 端点。] DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(标识符 userSuppliedIdentifier,Realm realm,Uri returnToUrl)+303 DotNetOpenAuth.AspNet.Clients.OpenIdClient.RequestAuthentication(HttpContextBase context,Uri returnUrl)+135 DotNetOpenAuth。 AspNet.OpenAuthSecurityManager.RequestAuthentication(String returnUrl) +666 NotesBoard.Controllers.ExternalLoginResult.ExecuteResult(ControllerContext context) 在 d:\dtaylor\Documents\Visual Studio 2012\Projects\NotesBoard\NotesBoard\Controllers\AccountController.cs:369 System.Web .Mvc.<>c_ DisplayClass1a.b _17() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func
1 continuation) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func
1 续) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 过滤器, ActionResult actionResult) +263 System.Web.Mvc.Async.<>c_ DisplayClass25.b _22(IAsyncResult asyncResult) +240 System .Web.Mvc.<>c_ DisplayClass1d.b _18(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.<>c_ DisplayClass4.b _3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.<>c_ DisplayClass4.b _3(IAsyncResult ar) +15 System.Web.Mvc.<>c_ DisplayClass8.b _3(IAsyncResult asyncResult) +42 System.Web.Mvc。异步。<>c_ DisplayClass4.b_3(IAsyncResult ar) +15 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
对于 Twitter,我得到:“连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机未能响应 199.16.156.72:443 ”,并带有以下堆栈跟踪
[SocketException (0x274c): 连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应 199.16.156.72:443] System.Net.Sockets.Socket.DoConnect (EndPoint endPointSnapshot, SocketAddress socketAddress) +273 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +584
[WebException: 无法连接到远程服务器] System.Net.HttpWebRequest.GetResponse() +8527180 DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +261
[ProtocolException: 发送直接消息或获取响应时发生错误。] DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +1862 DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request) +516 DotNetOpenAuth.Messaging.Channel .Request(IDirectedProtocolMessage requestMessage) +138 DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage) +45 DotNetOpenAuth.OAuth.ConsumerBase.PrepareRequestUserAuthorization(Uri 回调,IDictionary
2 requestParameters, IDictionary
2 redirectParameters, String& requestToken) +202 DotNetOpenAuth.AspNet.Clients.DotNetOpenAuthWebConsumer.RequestAuthentication(Uri callback) +88 DotNetOpenAuth.AspNet.OpenAuthSecurityManager.RequestAuthentication(String returnUrl) +666 NotesBoard.Controllers.ExternalLoginResult.ExecuteResult(ControllerContext context) in d: \dtaylor\Documents\Visual Studio 2012\Projects\NotesBoard\NotesBoard\Controllers\AccountController.cs:369 System.Web.Mvc.<>c_ DisplayClass1a.b _17() +33 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter过滤器,ResultExecutingContext preContext,Func1 continuation) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func
1 续) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 过滤器, ActionResult actionResult) +263 System.Web.Mvc.Async.<>c_ DisplayClass25.b _22(IAsyncResult asyncResult) +240 System .Web.Mvc.<>c_ DisplayClass1d.b _18(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.<>c_ DisplayClass4.b _3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.<>c_ DisplayClass4.b _3(IAsyncResult ar) +15 System.Web.Mvc.<>c_ DisplayClass8.b _3(IAsyncResult asyncResult) +42 System.Web.Mvc。异步。<>c_ DisplayClass4.b_3(IAsyncResult ar) +15 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
另一方面,Facebook 实际上提示我输入用户名和密码,但随后又返回“连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机未能响应 173.252 .100.27:443 " 和以下堆栈跟踪:
[SocketException (0x274c): 连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应 173.252.100.27:443] System.Net.Sockets.Socket.DoConnect (EndPoint endPointSnapshot, SocketAddress socketAddress) +273 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +584
[WebException: 无法连接到远程服务器] System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) +3624556 System.Net.WebClient.DownloadString(Uri address) +213 DotNetOpenAuth.AspNet.Clients.FacebookClient.QueryAccessToken( Uri returnUrl, String authenticationCode) +399 DotNetOpenAuth.AspNet.Clients.OAuth2Client.VerifyAuthentication(HttpContextBase context, Uri returnPageUrl) +186 DotNetOpenAuth.AspNet.OpenAuthSecurityManager.VerifyAuthentication(String returnUrl) +502 Microsoft.Web.WebPages.OAuth.OAuthWebSecurity.VerifyAuthenticationCore (HttpContextBase context, String returnUrl) +250 NotesBoard.Controllers.AccountController.ExternalLoginCallback(String returnUrl) in d:\dtaylor\Documents\Visual Studio 2012\Projects\NotesBoard\NotesBoard\Controllers\AccountController.cs:225 lambda_method(闭包,ControllerBase,对象[])+127 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary
2 parameters) +274 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2个参数) +39 System.Web.Mvc.Async.<>c_ DisplayClass39.b _33() +120 System.Web.Mvc.Async.<>c_ DisplayClass4f.b _49() +452 System.Web.Mvc.Async .<>c_ DisplayClass4f.b _49() +452 System.Web.Mvc.Async.<>c_ DisplayClass37.b _36(IAsyncResult asyncResult) +15 System.Web.Mvc.Async.<>c_ DisplayClass2a.b _20() +33 System.Web.Mvc.Async.<>c_ DisplayClass25.b _22(IAsyncResult asyncResult) +240 System.Web.Mvc.<>c_ DisplayClass1d.b _18(IAsyncResult asyncResult) +28 System.Web.Mvc.Async。 <> c_DisplayClass4.b_3(IAsyncResult ar) +15 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.<>c_ DisplayClass4.b _3(IAsyncResult ar) +15 System.Web.Mvc.< >c_ DisplayClass8.b _3(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>c_ DisplayClass4.b _3(IAsyncResult ar) +15 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
PS。值得一提的是,我们通过代理访问互联网,该代理设置在 IE 的服务器上。我在提供的模板中没有找到任何可以让我指定代理服务器等的代码。
请帮忙。