Question: How do I change the Facebook Redirect URL in an MVC5 webapp?


How do I change the Facebook Redirect URL in an MVC5 webapp?

Answers 1
Added at 2017-01-05 23:01

I've deployed my MVC5 application onto a server (was on localhost up until now), and now the Facebook authentication isn't working, because the redirect URL is still set to localhost. The link generated starts with:

How does it generate the redirect_uri? I need to specify my new server's address and thought it would be by changing the IISUrl property in the project's csproj file, but when I do, the project fails to load.

I've whitelisted the new URL at the Facebook side, I just can't work out how to tell my application itself that it has relocated (I'm guessing it's generating the value for the redirect_url parameter based on a value/setting somewhere in my application).

I'm using the Microsoft Owin packages, and the code to generate the button is:

@foreach (AuthenticationDescription p in loginProviders)
    <button type="submit" class="btn btn-default btn-block btn-social btn-@p.AuthenticationType.ToLower()" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in using your @p.Caption account">
          <i class="fa fa-@p.AuthenticationType.ToLower()"></i>


nr: #1 dodano: 2017-01-09 16:01

This is the way owin builds the redirect uri

string baseUri =
    Request.Scheme +
    Uri.SchemeDelimiter +
    Request.Host +

string redirectUri =
    baseUri +

where Options.Callbackpath defaults to /signin-facebook

Since your base uri is reading localhost make sure the server you deployed to isn't running on localhost and you are browsing to it with the correct domain name

Source Show
◀ Wstecz