将链接添加到验证摘要消息.net核心

时间:2018-08-18 07:17:58

标签: c# validation razor core

我找到了一个解决方案,但是我尝试的第一个在.net core中不起作用,或者我缺少一些using语句。基本上,我试图完成以下代码,以便在验证失败时在链接上显示在我的视图上:

var link = System.Net.WebUtility.HtmlEncode("<a href ='/account/resendconfirmationemail'>Resend confirm email</a>");
ModelState.AddModelError(string.Empty, $"You must have a confirmed email to log in. " + link);
return View(model);

这样我在视图上的验证消息将显示"Email confirmation needed, Click Here to resend confirmation link"并单击此处将是指向控制器/操作的链接

0 个答案:

没有答案
相关问题