i need to use forgot password functionality in mvc controller. With .net core 2.1 Identity part is separated in Area/Identity/Account
.
I need to use this part which generates URL for password reset.
var callbackUrl = Url.Page(
"/Account/ResetPassword",
pageHandler: null,
values: new { code },
protocol: Request.Scheme);
But I am not able to generate the url by the same way in my custom controller.
Any ideas how to generate URL for Page in action of common conroller?
var code = await _userManager.GeneratePasswordResetTokenAsync(applicationUser);
var callbackUrl = $"{Request.Scheme}://{Request.Host}/Identity/Account/ResetPassword?code={code}";
var callbackUrl = Url.Page(
"/Account/ResetPassword",
pageHandler: null,
values: new { area = "Identity", code },
protocol: Request.Scheme);
You will need to specify area as a value in using Url.Page to generate a correct link from with a mvc Controller. That will do the trick.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.