facebook - MVC3 Web 项目错误 : "An attempt was made to access a socket in a way forbidden by its access permissions 10.10.0.1:3128"

标签 facebook asp.net-mvc-3 azure

我将 MVC3 Web 项目发布到 Azure。当我尝试使用 Facebook 授权时,出现以下错误。

其他信息:

因此应用程序在 Facebook 上授权,转到 AddSocialAccount 操作并在字符串中失败:

var profile = this.Provider.GetUserProfile(code);

去哪里:

protected override Task<AccessGrant> PostForAccessGrantAsync(string accessTokenUrl, NameValueCollection request)
    {
        return this.RestTemplate.PostForObjectAsync<NameValueCollection>(accessTokenUrl, request)
            .ContinueWith<AccessGrant>(task =>
            {
                string expires = task.Result["expires"];
                return new AccessGrant(task.Result["access_token"], null, null, expires != null ? new Nullable<int>(Int32.Parse(expires)) : null);
            });
    }

有错误的字符串是

string expires = task.Result["expires"];

错误:

Server Error in '/' Application.
enter code here
An attempt was made to access a socket in a way forbidden by its access permissions 10.10.0.1:3128
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 10.10.0.1:3128
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: 
[SocketException (0x271d): An attempt was made to access a socket in a way forbidden by its access permissions 10.10.0.1:3128]
System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) +6462061
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +271
[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) +2233126
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult) +14
Spring.Http.Client.WebClientHttpRequest.ExecuteRequestCallback(IAsyncResult result) in f:\bamboo-home\xml-data\build-dir\SPRNETREST-RELEASE-JOB1\src\Spring.Rest\Http\Client\WebClientHttpRequest.cs:246
[AggregateException: One or more errors occurred.]
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) +3548265
System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) +73
System.Threading.Tasks.Task`1.get_Result() +10486829
Project.Social.Facebook.Api.Impl.FacebookOAuth2Template.<PostForAccessGrantAsync>b__0(Task`1 task) in D:\Code\Poll\Project.Social\Facebook\Api\Impl\FacebookOAuth2Template.cs:23
System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() +81
System.Threading.Tasks.Task.Execute() +49

[AggregateException: One or more errors occurred.]   
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) +3548265
System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) +73
System.Threading.Tasks.Task`1.get_Result() +10486829
Project.Social.Base.OAuth2SocialProvider`4.SetAccessToken(String code) in    D:\Code\Poll\Project.Social\Base\OAuth2SocialProvider.cs:49
Project.Social.Base.OAuth2SocialProvider`4.GetServiceClient(String oauth_verifier) in D:\Code\Poll\Project.Social\Base\OAuth2SocialProvider.cs:66
Project.Social.Facebook.FacebookProvider.GetUserProfile(String oauth_verifier) in D:\Code\Poll\Project.Social\Facebook\FacebookProvider.cs:26   Project.Areas.FrontEnd.Controllers.ControllersBase.OAuthControllerBase`3.AddSocialAccount(String code, String oauth_verifier) in D:\Code\Poll\Project\Areas\FrontEnd\Controllers\ControllersBase\OAuthControllerBase.cs:112
lambda_method(Closure , ControllerBase , Object[] ) +147
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +214
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
System.Web.Mvc.Controller.ExecuteCore() +106
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

当我使用带有 Azure 连接字符串的本地计算机时,我没有收到此错误(我更改了 fb 上的域和 url)。 感谢您的任何想法!

最佳答案

我解决了这个问题。我的 web.config 中有默认代理。

<system.net>
<defaultProxy>
  <proxy usesystemdefault="True" proxyaddress="http://10.10.0.1:3128" bypassonlocal="True" />
</defaultProxy>

我把它删除了。并且授权工作正确。

关于facebook - MVC3 Web 项目错误 : "An attempt was made to access a socket in a way forbidden by its access permissions 10.10.0.1:3128",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14871577/

相关文章:

c# - 如何解决 "Failed to bind to address http://127.0.0.1:5000: address already in use."

ios - Facebook SDK 登录对话框

python - 使用 TurboGears 的示例 Facebook 应用程序 -- pyFacebook

Facebook 应用程序 oauth 对话框错误

asp.net-mvc-3 - asp.NET MVC 3 复合模式模型绑定(bind)

c# - 在模型内的模型列表中添加项目

entity-framework - 具有 Entity Framework "DefaultConnection"应用程序设置的 Azure Key Vault

android - Facebook 返回错误的帖子评论数

c# - 如何映射 Controller 外部的相对路径?

azure - 如何将请求重定向到通过 Azure 应用服务托管的不同 Web 应用