Can you recommend a CAPTCHA library for use with an ASP.NET MVC application? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this questionIf you've incorporated CAPTCHA into an ASP.NET MVC application, did yo开发者_如何转开发u use an external CAPTCHA library of some kind? If so, would you recommend it and why?
- do you use nuget? if you don't, right click on the reference section of your project and choose ad library package reference
- get to the online tab, and install Microsoft Web Helpers dll
- In this refrence, you will find a very handy helper which is ReCaptcha.GetHtml
you can use it on your view as like below;
@ReCaptcha.GetHtml(ConfigurationManager.AppSettings["recaptcha-public-key"], "white")
I keep my recaptcah keys inside web.config so I used ConfigurationManager.AppSettings to reach them. You can get your own public and private keys from http://www.google.com/recaptcha
In your controller, it is very easy to handle the legitimate call like below;
if (ReCaptcha.Validate(ConfigurationManager.AppSettings["recaptcha-private-key"])) {
//the call is legitimate
} else {
// the call is not legitimate
}
I hope this helps.
Update 1 Uppps. don't forget to put the private and public keys inside you _ViewStart.cshtml file like below;
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ReCaptcha.PrivateKey = ConfigurationManager.AppSettings["recaptcha-private-key"];
ReCaptcha.PublicKey = ConfigurationManager.AppSettings["recaptcha-public-key"];
}
For an easy customisable one I would use: http://xcaptcha.codeplex.com/
For a standard complex one use: http://mvcrecaptcha.codeplex.com/
I agree with Lee Smit. I would recommend using MVCRecaptcha (https://mvcrecaptcha.codeplex.com/).
You can also download the package from Nuget, however, make SURE that you don't download the other Recaptcha packages that are available - you should specifically download MVC recaptcha.
Then follow the rest of the instructions on the MVC recaptcha codeplex site to get up and running.
精彩评论