title: ASP.NET Owin OAuth (Google / Facebook) is redirecting to default login.aspx insead of remote log in page
body: <p>I'm setting up OAuth using the Owin libraries including Google and Facebook.</p>
  
  <p>The Owin startup class is registering fine by the looks of it. What I'm finding is that rather than being redirected to the appropriate sign in page at Facebook or Google, I'm being redirected to a default 'login.aspx' page. There is no login.aspx page in my solution.</p>
  
  <p>The flow is triggered in a view like so:</p>
  
  <pre><code>@{
          // Get list of configured external authentication middleware
  
          var loginProviders = Context.GetOwinContext().Authentication.GetExternalAuthenticationTypes();
  
          if (!loginProviders.Any())
          {
              &lt;div&gt;
                  &lt;p&gt;There are no external authentication services configured&lt;/p&gt;
              &lt;/div&gt;
          }
          else
          {
              using (Html.BeginForm("ExternalLogin", "OAuth"))
              {
                  @Html.AntiForgeryToken()
  
                  &lt;div&gt;
                      &lt;p&gt;
                          @foreach (AuthenticationDescription p in loginProviders)
                          {
                              &lt;button type="submit" class="btn btn-default" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in using your @p.Caption account"&gt;@p.AuthenticationType&lt;/button&gt;
                          }
                      &lt;/p&gt;
                  &lt;/div&gt;
              }
          }
      }
  </code></pre>
  
  <p>This triggers the challenge result, however the challenge result simply causes a redirect to login.aspx (which again does not exist)</p>
  
  <pre><code>[HttpPost]
          [AllowAnonymous]
          [ValidateAntiForgeryToken]
          public ActionResult ExternalLogin(string provider)
          {
              string redirectUri = Url.Action("ExternalLoginCallback");
  
              // Request a redirect to the external login provider
              return new ChallengeResult(provider, redirectUri);
          }
  </code></pre>
  
  <p>What could I be missing?</p>
  
  <p>I've included the Startup.cs class for good measure:</p>
  
  <pre><code>public void Configuration(IAppBuilder app)
          {
  
              app.UseCookieAuthentication(
  
                 new CookieAuthenticationOptions
                 {
                     AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie
                 });
  
              app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
  
              app.UseFacebookAuthentication(new FacebookAuthenticationOptions
              {
                  AppId = Config.OAuthFacebookAppId,
                  AppSecret = Config.OAuthFacebookAppSecret,
                  Scope = { "email" }, // "email", also "publish_actions" can be included if post to facebook authorization is required
                  Provider = new FacebookAuthenticationProvider
                  {
                      OnAuthenticated = context =&gt;
                      {
                          context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
                          return Task.FromResult(true);
                      }
                  }
              });
  
              app.UseGoogleAuthentication(
                   clientId: Config.OAuthGoogleClientId,
                   clientSecret: Config.OAuthGoogleClientSecret
              );
          }
  </code></pre>