I wanted to generate a reset password link to send to the user's email that will open the ResetPassword page. On this page I will fill in the details regarding the new password and then confirm the password.
For this I have followed this Link
But there is a Url.Action method that i am not able to find in my web api project.
var callbackUrl = Url.Action(
"ConfirmEmail", "Account",
new { userId = user.Id, code = code },
protocol: Request.Url.Scheme);
Hase anybody done the reset password part in the web api? I need some help.
WebSecurity - ResetPassword() The ResetPassword() method resets a user password using a password token.
You can use Url.Link
in Web API 2.0
var callbackUrl = Url.Link("Default", new { Controller = "Account",
Action = "ConfirmEmail", userId = user.Id, code = code });
Url.Action does not exist because the Url helper in WebApi doe snot have the Action method. You can use Url.Route instead to generate the same thing but you will need to create a named route in order to use that method. If you are using attribute routing it, you can add a name to the route attribute like so:
[Route(Name="ConfirmEmail")]
and the helper would be
var callbackUrl = Url.Route("ConfirmEmail", new { userId = user.Id, code = code });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With