title: C# - Owin Oauth doesn't redirect to external login page
body: <p>Today i tried to implement external facebook login on my project.
  But when i try to login calling the method of ExternalLogin, this method does not return to Facebook login page</p>
  
  <p>I tried to do this:
  <a href="https://coding.abel.nu/2014/06/understanding-the-owin-external-authentication-pipeline/" rel="nofollow">https://coding.abel.nu/2014/06/understanding-the-owin-external-authentication-pipeline/</a></p>
  
  <p>And when i see my context the AuthenticationResponseChallenge is null.</p>
  
  <p>Follow the code:</p>
  
  <p>Startup.Auth.cs</p>
  
  <pre><code>     app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
  
          var fao = new FacebookAuthenticationOptions
          {
              AppId = APP_ID_FACEBOOK, //on Web.config
              AppSecret = APP_SECRET_FACEBOOK //on Web.config
          };
  
          fao.Scope.Add("email");
          fao.Scope.Add("basic_info");
  
          fao.Provider = new FacebookAuthenticationProvider()
          {
              OnAuthenticated = (context) =&gt;
              {
                  context.Identity.AddClaim(new System.Security.Claims.Claim("urn:facebook:access_token", context.AccessToken, XmlSchemaString, "Facebook"));
                  foreach (var x in context.User)
                  {
                      var claimType = string.Format("urn:facebook:{0}", x.Key);
                      string claimValue = x.Value.ToString();
                      if (!context.Identity.HasClaim(claimType, claimValue))
                          context.Identity.AddClaim(new System.Security.Claims.Claim(claimType, claimValue, XmlSchemaString, "Facebook"));
  
                  }
                  return Task.FromResult(0);
              }
          };
  
          fao.SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie;
          app.UseFacebookAuthentication(fao);
  </code></pre>
  
  <p>AccountController.cs</p>
  
  <pre><code>public ActionResult ExternalLogin(string provider, string returnUrl)
      {
  
          var result = new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Conta", new { ReturnUrl = returnUrl }));
          return result;
      }
  
  
      private const string XsrfKey = "XsrfId";
  
      internal class ChallengeResult : HttpUnauthorizedResult
      {
          public ChallengeResult(string provider, string redirectUri)
              : this(provider, redirectUri, null)
          {
          }
  
          public ChallengeResult(string provider, string redirectUri, string userId)
          {
              LoginProvider = provider;
              RedirectUri = redirectUri;
              UserId = userId;
          }
  
          public string LoginProvider { get; set; }
          public string RedirectUri { get; set; }
          public string UserId { get; set; }
  
          public override void ExecuteResult(ControllerContext context)
          {
              var properties = new AuthenticationProperties { RedirectUri = RedirectUri };
              if (UserId != null)
              {
                  properties.Dictionary[XsrfKey] = UserId;
              }
  
              context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
          }
      }
  </code></pre>
  
  <p>I tried to create an empty project with my facebook app credentials and worked fine, but in this project this don't work</p>
  
  <p>Anybody can help me?</p>