Azure emulator web site is not visible by Facebook

2019-05-27 03:14发布

问题:

My ASP.Net MVC3 web site that logs into Facebook is no longer working after moving to an Azure based cloud project. I am using the Azure SDK 1.6 and fail during the the OAuth steps.

I had a working site that ran locally at http://localhost:1200 which matched the Application Url setting that was registered for the application on Facebook. Now when I try to start the project in debug mode, it goes through the Azure emulator which maps the web site (role) to http://127.0.0.1:82/. I've tried updating the Facebook app url to the same address but it fails.

I've been investigating this and I've noticed that the Azure emulator automatically creates on the fly a new IIS web site and employs a load balancer for its created virtual IPs for the individual projects within the cloud solution. Is there a way to get a project to debug successfully and still talk to Facebook when running the Azure emulator within Visual Studio?

Any insight is greatly appreciated.

回答1:

I would not use localhost for Facebook applications.

What I did, I had registered my real domain in Facebook (such as myapp.com) Then I created a record in my hosts file (Windows\system32\drivers\etc\hosts)

127.0.0.1 dev.myapp.com

which is sub-domain of my production domain, so it's allowed by FB;

And then I used dev.myapp.com as callback address for Facebook; I also setup Visual Studio to run http://dev.myapp.com:anyport on start application debugging.