Asp.net mvc 如何在服务器端验证CaptchaMVC?
我正在Asp.net MVC项目中使用CaptchaMVC。下面是我的客户端代码。我将此验证码发布到操作方法。我被困在如何验证这个验证码在服务器端。 下面是我的验证码控制Asp.net mvc 如何在服务器端验证CaptchaMVC?,asp.net-mvc,Asp.net Mvc,我正在Asp.net MVC项目中使用CaptchaMVC。下面是我的客户端代码。我将此验证码发布到操作方法。我被困在如何验证这个验证码在服务器端。 下面是我的验证码控制 <div class="form-group"> @Html.Hidden(MvcApplication.MultipleParameterKey, 2) @Html.Captcha("Refresh", "", 5, "<span style='color:red'>"+General
<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>
@隐藏(mvcapapplication.MultipleParameterKey,2)
@Html.Captcha(“Refresh”、“”、5、“+Generals.captchrequired+”,true,新参数模型(mvcapapplication.MultipleParameterKey,2))
@ViewBag.message
您只需在您的操作方法上添加上面的[CaptchaVerify(“Captcha无效”)]过滤器,如下所示
[HttpPost, CaptchaVerify("Captcha is not valid")]
public ActionResult Index(YourModelclass obj)
{
if (!ModelState.IsValid)
{
return View("Index", obj);
}
}