如何在带有验证码验证的MVC应用程序中使用全局资源?

时间:2019-05-02 12:51:03

标签: model-view-controller captcha asp.net-mvc-validation

我具有以下验证验证码的属性:

[CaptchaValidation("CaptchaCode", "ForgotPasswordCaptcha", "Are You A Robot?")]

我的控制器方法使用该属性来验证ModelState:

[HttpPost]
[ActionName("ForgotPassword")]
[CaptchaValidation("CaptchaCode", "ForgotPasswordCaptcha", "Are You A Robot?")]
public ActionResult GetNewPassword(ForgotPasswordModel model, string returnUrl)
{
      if(ModelState.IsValid)
      {
           //do something
      }
      else
      {
           return View();
      }
}

这种方法可以正常工作,但是我需要更改错误消息,使其来自我的Global.resx文件。

我该怎么做?

0 个答案:

没有答案