title: How to obtain email address from Facebook using ASP.MVC and DotNetOpenAuth
body: <p>I'm trying to set up authentication in my app. I have the posting to the external website working (facebook and google)</p>
  
  <pre><code>[AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get), ValidateInput(false)]
      public ActionResult OpenIdLogOn(string returnUrl)
      {
          var redirectUrl = "~/Companies/LogIn";
          var provider = Request.Form["provider"];
          if (Common.IsNull(provider))
              return View();            
          OpenAuth.RequestAuthentication(provider, redirectUrl);
          return View();
      }
  </code></pre>
  
  <p>This works by figuring out what button was clicked (Login with facebook / Google) Then requests authentication. When the authentication has finished and I get a post back, I try to retrieve the email address.</p>
  
  <pre><code>public ActionResult LogIn()
      {
          var redirectUrl = "~/Companies/LogIn/OpenIdLogOn";
          var response = Response;
          var userEmail = Request.Params[16];
          if (!String.IsNullOrEmpty(ReturnUrl))
          {                
              Response.Redirect("~/Bloggers");
          }
  
          ViewBag.OAuthProviders = OpenAuth.AuthenticationClients.GetAll().ToList();
          return View();
      }
  </code></pre>
  
  <p>The following will work if I log in with google -</p>
  
  <pre><code>var userEmail = Request.Params[16];
  </code></pre>
  
  <p>but facebook doesn't send the email back. Well I cant see it in the request. There must be a better way of doing this than using <code>Request.Params[16];</code> 
  also. Help would be much appreciated.</p>