title: Asp.net Login providers by using Owin external login In a Pop Up Window
body: <p>I'm using MVC with Owin external login.</p>
  
  <p>Owin doesn't open login as popup.
  It redirects the page to that login provider.</p>
  
  <p>For example
  If i want to login through facebook it will not open facebook login in a popup window rather it redirects to facebook login page.</p>
  
  <p>So far with my R&amp;D i have found that I have to create an authentication provider for Facebook. So create a class that inherits from FacebookAuthenticationProvider. Within this class, override the "ApplyRedirect" method.</p>
  
  <p>Here is my sample code :</p>
  
  <pre><code>public class FacebookProvider : FacebookAuthenticationProvider
  {
      public override void ApplyRedirect(FacebookApplyRedirectContext context)
      {
          context.Response.Redirect(context.RedirectUri + "&amp;display=popup");
      }
  }
  </code></pre>
  
  <p>and i wire this code in my startup.auth.cs class like this:</p>
  
  <pre><code> app.UseFacebookAuthentication(new FacebookAuthenticationOptions
          {
              Provider = new FacebookProvider(), 
              AppId = "xxxxxxxxxx",
              AppSecret = "647e05af9188a8a3ccd0793aae9a846f",
              Scope = { "email" },
              SignInAsAuthenticationType = Microsoft.Owin.Security.AppBuilderSecurityExtensions.GetDefaultSignInAsAuthenticationType(app)
          });
  </code></pre>
  
  <p>and my _ExternalLoginListPartial.cshtml is like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@using Microsoft.Owin.Security
  
  &lt;h4&gt;Use another service to log in.&lt;/h4&gt;
  &lt;hr /&gt;
  @{
      var loginProviders = Context.GetOwinContext().Authentication.GetExternalAuthenticationTypes();
      if (loginProviders.Count() == 0) {
          &lt;div&gt;
              &lt;p&gt;
                  There are no external authentication services configured. See &lt;a href="http://go.microsoft.com/fwlink/?LinkId=403804"&gt;this article&lt;/a&gt;
                  for details on setting up this ASP.NET application to support logging in via external services.
              &lt;/p&gt;
          &lt;/div&gt;
      }
      else {
          using (Html.BeginForm("ExternalLogin", "CustomerAccount", new { ReturnUrl = Model.ReturnUrl })) {
              @Html.AntiForgeryToken()
              &lt;div id="socialLoginList"&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>
  </div>
  </div>
  </p>
  
  <p>So if there is any way i can solve my problem.. i have spend like 5 days to solve this issue ..</p>