After a user logs in with their Google profile I am trying to redirect them back to the home page, however it keeps redirecting to default.aspx.
The line above the return in the code below is what I am using to try to redirect.
[System.Web.Mvc.AcceptVerbs(HttpVerbs.Post)]
public ActionResult Logon(string loginIdentifier)
{
if (!Identifier.IsValid(loginIdentifier))
{
ModelState.AddModelError("loginIdentifier", "The specified login identifier is invalid");
return View();
}
else
{
var openId = new OpenIdRelyingParty();
IAuthenticationRequest request = openId.CreateRequest(Identifier.Parse(loginIdentifier));
// Require some additional data
request.AddExtension(new ClaimsRequest
{
BirthDate = DemandLevel.NoRequest,
Email = DemandLevel.Require,
FullName = DemandLevel.Require
});
request.AddCallbackArguments("http://localhost:5977/Home/About", "http://localhost:5977/Home/About");
return request.RedirectingResponse.AsActionResult();
}
}
Any help would be appreciated, thanks!
Adding a callback argument doesn’t control where the user goes when login has completed. Rather, web.config sets the default redirect behavior:
Ultimately this can be overridden in your controller where you call
RedirectFromLoginPageto instead useSetAuthCookieand then redirect manually. But you should typically have the right home page URL listed in your web.config file anyway, in which case the right thing happens.