English 中文(简体)
随机港口的Facebook OAuth + AppHarbor workaround
原标题:Facebook OAuth + AppHarbor workaround on random port

I a have a sample app, hosted on AppHarbor and now want to integrate authorization through facebook. So i downloaded nugget Facebook.Web.Mvc package to implement it.

阅读辅导后,控制器有以下方法:

 public ActionResult Login(string returnUrl)
    {
        var oauthClient = new FacebookOAuthClient(FacebookApplication.Current) { RedirectUri = GetFacebookRedirectUri() };


        if (!string.IsNullOrWhiteSpace(returnUrl))
        {
            returnUrl = Url.Action("Index", "Facebook");
        }

        dynamic parameters = new ExpandoObject();
        parameters.scope = ExtendedPermissions;

        var state = new { csrf_token = CalculateMD5Hash(Guid.NewGuid().ToString()), return_url = returnUrl };
        parameters.state = Base64UrlEncode(Encoding.UTF8.GetBytes(JsonSerializer.Current.SerializeObject(state)));
        SetFacebookCsrfToken(state.csrf_token);

        string s = oauthClient.GetLoginUrl(parameters).AbsoluteUri;

        ViewBag.FacebookLoginUrl = s;
        //new LogEvent(s).Raise();

        return View(new AccountModel());
    }

观点:

<a href="@ViewBag.FacebookLoginUrl" id="lUrl">
<div class="fblogin"></div>

In localhost this works for me. But when i upload it to appharbor, i see, that generated link indicates to address + port 16013 (as support told always random port). So clicking it shows me facebook login window, than blank page.

我用手法将我的补给环境配置到该港口,但没有帮助。

Also i tried to access my site through this port - nothing.

然后,通过舱位将港口数量改为80个,这也无助于。

you have had such problems?

问题回答

I m not familiar with the Facebook api, but I ve had a similar problem. I suspect that the returnUrl value being passed in is incorrect. It probably contains a port number that AppHarbor uses internally for load balancing.

See this article on how to create a public url for AppHarbor: http://support.appharbor.com/kb/getting-started/workaround-for-generating-absolute-urls-without-port-number

然后确保你返回的价值 乌尔都语是公开的。

您现在可以制定有效解决这一问题的<代码>aspnet:UseHost HeaderForRequestUrl appSetting to true。 可以通过在你的申请中添加一个可与相应的关键和价值相匹配的配置。





相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签