I installed the captcha plugin and followed the installation instructions. Captcha renders the page perfectly, but when submitting a form, the ModelState.IsValid model is always true no matter what I enter. Obviously, if captcha will not check, then this is not very good for me.
Here is my controller:
[HttpPost]
[CaptchaValidation("CaptchaCode", "SampleCaptcha", "Incorrect CAPTCHA code!")]
public ActionResult Register(AccountModel model)
{
if (!ModelState.IsValid)
{
}
else
{
}
return View();
}
And here is my view:
<link href="@BotDetect.Web.CaptchaUrls.Absolute.LayoutStyleSheetUrl" rel="stylesheet" type="text/css" />
<form class="form-horizointal" action="@Url.Action("Register", "Account")" method="POST">
<div class="form-group">
@Html.LabelFor(m => m.FirstName, new { @class = "col-sm-2 control-label" })
@Html.TextBoxFor(m => m.FirstName, new { placeholder = "First Name"})
@Html.LabelFor(m => m.LastName, new { @class = "control-label", placeholder = "Last Name" })
@Html.TextBoxFor(m => m.LastName, new { placeholder = "Last Name" })
</div>
<div class="form-group">
@Html.LabelFor(m => m.Email, new {@class = "col-sm-2 control-label", placeholder = "Email"})
@Html.TextBoxFor(m => m.Email, new {placeholder = "Email"})
</div>
<div class="form-group">
@{ MvcCaptcha sampleCaptcha = new MvcCaptcha("SampleCaptcha"); }
@Html.Captcha(sampleCaptcha)
@Html.TextBox("CaptchaCode")
</div>
<div class="form-group">
captcha goes here
</div>
<div class="form-group">
<input type="submit" class="btn btn-default" value="Register"/>
</div>
</form>
Does anyone know why this is not working for me? Thank you for your help!
source
share