验证码使用与ASP.NET MVC [英] Using reCAPTCHA with ASP.NET MVC

查看:76
本文介绍了验证码使用与ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的reCAPTCHA在我的WebForms应用的许多倍。现在我想将它添加到ASP.NET MVC应用程序。

I've used reCAPTCHA many times in my WebForms applications. Now I'd like to add it to an ASP.NET MVC application.

我发现了什么似乎是在<一个一些好的code href=\"https://$c$c.google.com/p/recaptcha/source/browse/trunk/recaptcha-plugins/dotnet/library/RecaptchaControlMvc.cs?r=125\"相对=nofollow> RecaptchaControlMvc ,但不可思议的是,我一直没能找到关于如何使用这种控制一个段落或例子。

I found what appears to be some good code in RecaptchaControlMvc but, incredibly, I haven't been able to find a single paragraph or example on how to use this control.

我已经发布了谷歌验证码组中,但它已经死了。

I've posted in the Google reCAPTCHA group but it's dead.

任何人都可以点我使用这个控制,如何使用它,或建议的替代款的例子吗?

Can anyone point me to an example that uses this control, a paragraph about how to use it, or suggest an alternative?

注:我知道有计算器上类似的问题,但没有我发现讨论如何使用这种控制

推荐答案

有些code <一个href=\"http://devlicio.us/blogs/derik_whittaker/archive/2008/12/02/using-recaptcha-with-asp-net-mvc.aspx\"相对=nofollow>这里

您添加这个属性:

[CaptchaValidator]  
[AcceptVerbs( HttpVerbs.Post )]  
public ActionResult SubmitForm( Int32 id, bool captchaValid )  
{  
.. Do something here  
}  

您呈现的验证码在您的视图:

You render the captcha in your view:

<%= Html.GenerateCaptcha() %> 

这是这样的:

public static string GenerateCaptcha( this HtmlHelper helper )  
{           
    var captchaControl = new Recaptcha.RecaptchaControl  
            {  
                    ID = "recaptcha",  
                    Theme = "blackglass",  
                PublicKey = -- Put Public Key Here --,  
                        PrivateKey = -- Put Private Key Here --  
            };  

    var htmlWriter = new HtmlTextWriter( new StringWriter() );  
    captchaControl.RenderControl(htmlWriter);  
    return htmlWriter.InnerWriter.ToString();  
}  

这篇关于验证码使用与ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆