public ActionResult LogOn() { IAuthenticationResponse response = openId.Response; if (response != null) { if ((response.Status == AuthenticationStatus.Failed) || (response.Status == AuthenticationStatus.Canceled)) { ModelState.AddModelError(ModelStateUserNameKey, TextMessages.UnableToLoginWithYourPreferredOpenIDProvider); } else if (response.Status == AuthenticationStatus.Authenticated) { string userName = response.ClaimedIdentifier; ClaimsResponse fetch = response.GetExtension <ClaimsResponse>(); // Some of the Provider does not return Email // Such as Yahoo, Blogger, Bloglines etc, in that case email will be null string email = (fetch != null) ? fetch.Email : null; UserResult result = userService.Save(userName, email); ModelState.Merge(result.RuleViolations); if (ModelState.IsValid) { bool persistCookie = cookie.GetValue <bool>(CookieRememberMe); formsAuthentication.SetAuthenticationCookie(userName, persistCookie); string returnUrl = cookie.GetValue <string>(CookieReturnUrl); return(Redirect(returnUrl ?? Url.Home())); } } } return(View()); }