我想在电子邮件中发送密码重置功能的链接。这是我想出来的最好的。
string link = string.Format("<a href='{0}://{1}{2}'>Click here.</a>",
Request.Url.Scheme, Request.Url.Authority,
Url.Action("ResetPasswordAction", new { passwordToken = token }));
有更优雅的解决方案吗?
答案 0 :(得分:1)
查看HtmlHelper.GenerateRouteLink
它应该导致:
HtmlHelper.GenerateRouteLink(Request.RequestContext,
RouteTable.Routes,
"Click here.",
targetRouteName,
Request.Url.Scheme,
Request.Url.Authority,
"",
new RouteValueDictionary(new { action = "ResetPasswordAction", controller = "YourController", passwordToken = token }),
new Dictionary<string, object>()
);
虽然我不确定它是“更优雅”,但我希望这无论如何都会有所帮助