DotNetOpenAuth...CreatRequest breaks on server (Works on my machine ;
I've created a site based on the ASP.NET MVC 4 Web Application. I have enabled the OpenAuth login providers for Twitter, Facebook and Google by following the instructions in AuthConfig.cs.
This works fine when the site is debugged on my local machine from Visual Studio on IIS Express. However, when I copy the site over to another machine, the entire site works fince, except anything that uses open auth.
On this machine I can access twitter, facebook and google using the browser.
When I try to log on using my site I get: for Google: " Sequence contains no elements " with the stacktrace pointing at
[InvalidOperationException: Sequence contains no elements] System.Linq.Enumerable.First(IEnumerable`1 source) +514 DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) +106
[ProtocolException: No OpenID endpoint found.] DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier 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) in d:dtaylorDocumentsVisual Studio 2012ProjectsNotesBoardNotesBoardControllersAccountController.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 continuation) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerC ontext controllerContext, IList`1 filters, 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.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
For Twitter I get: " A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 199.16.156.72:443 " with the following Stack trace
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 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: Unable to connect to the remote server] System.Net.HttpWebRequest.GetResponse() +8527180 DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +261
[ProtocolException: Error occurred while sending a direct message or getting the response.] 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 callback, 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:dtaylorDocumentsVisual Studio 2012ProjectsNotesBoardNotesBoardContro llersAccountController.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 continuation) +613 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, 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.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
Facebook on the other hand actually prompts me for a username and password but then also comes back with " A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 173.252.100.27:443 " and the following stack trace:
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 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: Unable to connect to the remote server] System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) +3624556 System.Net.WebClient.DownloadString(Uri address) +213 DotNetOpenAuth.AspNet.Clients.FacebookClient.QueryAccessToken(Uri returnUrl, String authorizationCode) +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:dtaylorDocumentsVisual Studio 2012ProjectsNotesBoardNotesBoardControllersAccountController.cs:225 lambda_method(Closure , ControllerBase , Object[] ) +127 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary 2 parameters) +274 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +274 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +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. It's worth mentioning that we access the internet via a proxy, which is set up on the server in IE. I haven't found any code in the provided templates that let me specify proxy servers etc.
Help please.
I think I was able to resolve this issue. It turns out that our proxy server seems to have been the issue. I had the Application pool that was running this site in IIS configured to use NetworkServices as the Application Pool Identity. I changed the Identity to run as myself to see if the problem was resolved and it was. It's obviously not recommended to have a site run as a user account, so I will be requesting our IT team to create a domain account for this site, that also has access through our proxy servers.
I hope that helps someone else having the same problem.
链接地址: http://www.djcxy.com/p/72694.html