我需要向用户发送电子邮件,以便重置密码。其中包含用于打开网站中的“密码重置”页面的链接。 这两个网站和web api在同一个域中。但不同的解决方案。
我在web api中创建了一个链接。
var callbackUrl = Url.Link("ResetPassword", new { Controller = "Account", code = token });
但是当它在邮递员上进行测试时,它会显示' ResetPassword'在路线集合中找不到。 网站的帐户控制器中有ResetPassword ActionResult。
[AllowAnonymous]
[Route(Name="ResetPassword")]
public ActionResult ResetPassword(string code)
{
return code == null ? View("Error") : View();
}
RegisterRoutes
方法是,
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
我还没有部署解决方案。 它可以用于部署吗?
答案 0 :(得分:0)
您基本上错误地将路线名称与操作名称放错了地方。请尝试使用此:
var callbackUrl = Url.Link("Default", new { Controller = "Account", Action ="ResetPassword", code = token });