潜在的针对dasBlog(及其他)的CAPTCHA评论垃圾邮件解决方案,无需重新编译或更改代码...

I took Jeff Atwood's CAPTCHA example and added a new event called "UserValidationEvent"

我以Jeff Atwood的CAPTCHA示例为例,并添加了一个名为“ UserValidationEvent”的新事件

Public Event UserValidationEvent As EventHandler

公共事件UserValidationEvent作为EventHandler

Then I raise the event at the VERY end of ValidateCaptcha I raise it:

然后,我在ValidateCaptcha的非常结尾处引发该事件:

RaiseEvent UserValidationEvent(Me, New EventArgs)

RaiseEvent UserValidationEvent(Me,New EventArgs)

I made it a separate event because I want the CaptchaControl to integrate with my blogging software WITHOUT any code on the server side.  I didn't want to have to recompile dasBlog or check anything in the Page_Load.

我将其设置为一个单独的事件是因为我希望CaptchaControl与我的博客软件集成,而无需在服务器端添加任何代码。 我不想重新编译dasBlog或检查Page_Load中的任何内容。

I made the appropriate web.config changes as per Jeff's instructions, and I added the control to the CommentViewBox.ascx and put this code at the top:

我按照Jeff的说明进行了适当的web.config更改,并将控件添加到CommentViewBox.ascx并将此代码放在顶部:

<%@ Register TagPrefix="cc1" Namespace="WebControlCaptcha" Assembly="WebControlCaptcha" %>
<script Language="C#" Runat="Server">
  protected void Foo(object sender, System.EventArgs e)
  {
  if (Page.IsPostBack == true && CaptchaControl1.UserValidated == false)
   {
    Response.Redirect(Request.RawUrl);
   }
  }

<%@注册TagPrefix =“ cc1”命名空间=“ WebControlCaptcha”程序集=“ WebControlCaptcha”%> <脚本语言=“ C#” Runat =“ Server”> 受保护的void Foo(对象发送者,System.EventArgs e) { 如果(Page.IsPostBack == true && CaptchaControl1.UserValidated == false) { Response.Redirect(Request.RawUrl); } }

  protected void Page_Load(object sender, System.EventArgs e)
  {
   //Ya, ya, I know I could have hooked this event up a number of ways
   // including AutoEventWireUp but I like this fine, and it feels
   // more explicit to moi.
   CaptchaControl1.UserValidationEvent += new EventHandler(Foo);
  }  
</script>

受保护的void Page_Load(对象发送者,System.EventArgs e) { //是的,我知道我可以通过多种方式来挂起此事件//包括AutoEventWireUp,但我很好,感觉//对moi更明确。 CaptchaControl1.UserValidationEvent + =新的EventHandler(Foo); } </ script>

There are a few Font issues to work out...he has it setup with a number of "no-no" fonts, while I'd prefer a list of "allowed" fonts. 

有一些字体问题需要解决...他为它设置了许多“禁止”字体,而我希望使用“允许”的字体列表。

翻译自: https://www.hanselman.com/blog/a-potential-captcha-comment-spam-solution-for-dasblog-and-others-with-no-recompile-or-code-changes

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值