ASP.NET CAPTCHA Problem Control Sample with ASP.NET MVC

I am trying to use the following CAPTCHA Server Control for ASP.NET - Jeff Atwood on an ASP.NET MVC site. The custom control doesn't seem to validate when the form is submitted.

Is there anyone who worked with this example using ASP.NET MVC?

The main code I'm using looks like this:

<% using (Html.BeginForm()) { %>
<CaptchaControl:CaptchaControl ID="CaptchaControl" Name="Security" runat="server"></CaptchaControl:CaptchaControl>
<input type="submit" value="Send Message" />
<% } %>

      

+2


source to share


3 answers


It is actually not recommended to use ASP.Net controls for ASP.Net MVC site. ASP.Net MVC does not follow the page lifecycle like regular ASP.Net does. Server controls can be displayed, but if they rely on ViewState or Postback events, they will not work.



Looking at the code for Captcha Control it seems to be the problem. The check is performed during the LoadPostBackData loading process. Unfortunately there is no postback concept in ASP.Net MVC ... and hence no postback data.

+1


source


I wrote a complete blog post about the ASP.NET MVC control. It might be worth taking a look at as it is very updated:



ASP.NET MVC Captcha Control

+1


source


Better choice is to just use reCaptchaMvcExtensions from the NuGet Package Library. This is an easy to install and use package that uses the full Google reCaptcha.

0


source







All Articles