自從三年多前加裝了TrimothyHUmphrey’s CAPTCHA,一直以來抵抗垃圾留言效果還不錯,但最近似乎有被攻破的嫌疑,隔一陣子會密集冒出好幾則無意義的洋文垃圾留言:

最近兩次都是一口氣被塞了10則以上,刪留言刪到火氣都上來了。心一橫,決定換上口碑不錯的reCAPTCHA,看看是否防禦效果會更好些。(延伸閱讀: 介紹好用工具:reCAPTCHA (免費的 CAPTCHA 驗證服務) by 保哥)

說來reCAPTCHA是個有趣的點子,特別挑選OCR程式無法識別的紙本掃瞄內容當考題,自然可難倒一大票破解程式;而使用者回答的結果,又能回饋協助識別OCR工程中電腦無能為力的部分,一舉兩得,真是妙極了。

不過,連夜安裝Recaptcha.dll到Hosting環境時,冒出個小插曲。由於Hosting環境ASP.NET程式並不是用FullTrust權限等級在執行,造成一引用<recaptcha:RecaptchaControl />就會爆出以下錯誤:

[SecurityException: That assembly does not allow partially trusted callers.]
   ASP.themes_blogs_gold_coast_post_aspx.__BuildControl__control65() +0
   ASP.themes_blogs_gold_coast_post_aspx.__BuildControl__control43(Control __ctrl) +953
   System.Web.UI.CompiledTemplateBuilder.InstantiateIn(Control container) +12
   CommunityServer.Controls.WrappedFormBase.AddFormControls() in WrappedFormBase.cs:425
   CommunityServer.Controls.WrappedFormBase.CreateControlHierarchy() in WrappedFormBase.cs:390
   CommunityServer.Controls.WrappedFormBase.CreateChildControls() in WrappedFormBase.cs:367
   System.Web.UI.Control.EnsureChildControls() +87

明明本機測試OK,一上傳到正式主機卻把網站搞爛,讓我嚇出一身冷汗。爬了文,找到好心網友給的解決方案 --- 加註: [assembly: System.Security.AllowPartiallyTrustedCallers]後重Build Recaptcha.dll。

重新編譯、上傳,總算問題排除,結束了驚險的程式上線夜。大家如發現它運作有問題,請再回饋給我,感謝!


Comments

# by Alan

黑大! 可以提供重Build過後的dll檔開放給大家下載嗎? 感謝

# by Jeffrey

to Alan, 我是抓網路上的Source(http://goo.gl/TRQRt)重Build,裡面原本已現成的DLL,但我直接放在專案中Reference DLL不OK,把Recaptcha專案納進Soluction並直接參照專案重Build整個網站才過關。以上經驗供參。

Post a comment