Reputation: 69
I have little problem with my api and its account-management. Whenever a user creates a new account, it has to be confirmed by clicking on a link that is sent by email. That works perfectly fine. However, when the user clicks on the link, it opens up a blank browser window. Now I'd like to redirect the user to a webpage that offers instructions for the application. After a bit of research, I found the "redirect(string url)" command.
[HttpGet]
[AllowAnonymous]
[Route("ConfirmEmail", Name = "ConfirmEmailRoute")]
public async Task<IHttpActionResult> ConfirmEmail(string userId = "", string code = "")
{
if (string.IsNullOrWhiteSpace(userId) || string.IsNullOrWhiteSpace(code))
{
ModelState.AddModelError("", "User Id and Code are required");
return BadRequest(ModelState);
}
IdentityResult result = await this.AppUserManager.ConfirmEmailAsync(userId, code);
if (result.Succeeded)
{
Redirect("http://www.orf.at");
return Ok();
}
else
{
return GetErrorResult(result);
}
}
The address should only be an example. Whenever one clicks on a link, however, the browser still opens a blank tab. Is there a possibility to avoid that? The best solution would be to redirect the user to another site. But if that does not work, can it somehow be prevented that a new window is opened up?
Upvotes: 1
Views: 2206
Reputation: 190907
Instead of returning Ok()
return Redirect("http://www.orf.at");
if (result.Succeeded)
{
return Redirect("http://www.orf.at");
}
else
{
return GetErrorResult(result);
}
Upvotes: 3