我在Asp.net MVC项目中使用CaptchaMVC。下面是我的客户端代码。我将此Captcha发布到一个动作方法。我被困在如何验证服务器端的这个Captcha。 我在View中的Captcha控件位于
之下<div class="form-group">
@Html.Hidden(MvcApplication.MultipleParameterKey, 2)
@Html.Captcha("Refresh", "", 5, "<span style='color:red'>"+Generals.captchrequired+"</span>", true, new ParameterModel(MvcApplication.MultipleParameterKey, 2))
<label class="text-danger">@ViewBag.message</label>
</div>
答案 0 :(得分:0)
您只需在您的操作方法上添加[CaptchaVerify(&#34; Captcha无效&#34;)]过滤器,如下所示
[HttpPost, CaptchaVerify("Captcha is not valid")]
public ActionResult Index(YourModelclass obj)
{
if (!ModelState.IsValid)
{
return View("Index", obj);
}
}