Create Mathematical Captcha In ASP.NET MVC

In this article, I will explain that how to create Mathematical Captcha to ASP.NET MVC project.

Well, it is most similar to normal Captcha. There is a minor difference between them.

Note: The controller code and the Success view are the same as in the previous article. The change is only in the Index view.

Here is the View

The change is, you just need to remove @Html.Captcha(5) and add@Html.MathCaptcha(). It will display Mathematical Captcha.

@using CaptchaMvc.HtmlHelpers;
@{
    ViewBag.Title = "Home Page";
}
@using (Html.BeginForm("ValidateCaptcha", "Home", FormMethod.Post))
{
    <div class="container" id="CaptchaDiv">
        <h3>Captcha Demo</h3>
        <div class="row">
            <div class="col-lg-4 form-group">
                @Html.MathCaptcha()
                @*@Html.Captcha(5)*@
                <br />
                <span style="color:red">@ViewBag.error</span>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-4">
                <input type="submit" class="btn btn-primary" id="btnSubmit" value="Submit" />
            </div>
        </div>
    </div>
}

#viastudy

Post a Comment

0 Comments