我使用VisualStudio 2013預覽的MVC5模板,它有很好的Startup.Auth.cs配置,它可以跨越我嘗試的所有社交域。然而FaceBook要求你指定返回主機。精細。所以我有一個用於本地主機的Facebook應用和一個用於部署應用的Facebook應用。我希望應用程序知道它的部署位置並傳遞適當的密鑰,但在Startup.Auth.cs位置中遇到問題。有沒有更好的地方可以做到這一點?使用FaceBook OAuth mvc5與不同的LocalHost和部署密鑰
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseSignInCookies();
// Uncomment the following lines to enable logging in with third party login providers
//app.UseMicrosoftAccountAuthentication(
// clientId: "",
// clientSecret: "");
if (HttpContext.Current.Request.IsLocal)
{
app.UseFacebookAuthentication(
appId: "1234localid",
appSecret: "123123123123123");
}
else
{
app.UseFacebookAuthentication(
appId: "4321deployid",
appSecret: "123123123123123");
}
這似乎總是解決第二個選項。就好像/AppStart/Startup.Auth.cs已解析,它不知道它何時IsLocal。