如果您已将CAPTCHA合并到ASP.NET MVC应用程序中,您是否使用了某种外部CAPTCHA库?如果是这样,你会推荐它吗?为什么?
答案 0 :(得分:4)
您可以在视图中使用它,如下所示;
@ReCaptcha.GetHtml(ConfigurationManager.AppSettings["recaptcha-public-key"], "white")
我将recaptcah密钥保存在web.config中,因此我使用ConfigurationManager.AppSettings来访问它们。您可以从http://www.google.com/recaptcha
获取自己的公钥和私钥在你的控制器中,很容易处理下面的合法调用;
if (ReCaptcha.Validate(ConfigurationManager.AppSettings["recaptcha-private-key"])) {
//the call is legitimate
} else {
// the call is not legitimate
}
我希望这会有所帮助。
更新1 Uppps。不要忘记将私人和公钥放在你的_ViewStart.cshtml文件中,如下所示;
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ReCaptcha.PrivateKey = ConfigurationManager.AppSettings["recaptcha-private-key"];
ReCaptcha.PublicKey = ConfigurationManager.AppSettings["recaptcha-public-key"];
}
答案 1 :(得分:1)
对于一个易于定制的,我会使用:http://xcaptcha.codeplex.com/
对于标准复杂的使用:http://mvcrecaptcha.codeplex.com/
答案 2 :(得分:0)
我同意Lee Smit的观点。我建议使用MVCRecaptcha(https://mvcrecaptcha.codeplex.com/)。
您也可以从Nuget下载该软件包,但是,请确保您没有下载其他可用的Recaptcha软件包 - 您应该专门下载MVC recaptcha。
然后按照MVC recaptcha codeplex站点上的其余说明启动并运行。