Recaptcha 不会使用 Recaptcha.dll 在 DNN 模块中动态加载
Recaptcha doesn't load dynamically in DNN module using Recaptcha.dll
当我尝试在代码隐藏中动态分配 Public 和私钥时,加载 Google Recaptcha 控件时遇到问题。它在简单的 ASP.Net 网站上工作正常,但当我将它集成到 DNN 模块中时它不起作用。
错误消息: reCAPTCHA 需要配置 public 和私钥。
堆栈跟踪:
DotNetNuke.Services.Exceptions.PageLoadException: reCAPTCHA needs to be configured with a public & private key. ---> System.ApplicationException: reCAPTCHA needs to be configured with a public & private key. at Recaptcha.RecaptchaControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at DotNetNuke.UI.Modules.ModuleHost.InjectModuleContent(Control content) at DotNetNuke.UI.Modules.ModuleHost.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
标记:
<googleCaptcha:RecaptchaControl ID="ctlRecaptcha" runat="server" />
代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
ctlRecaptcha.PublicKey = "xyz";
ctlRecaptcha.PrivateKey = "abc";
}
我实际上有一个关于 DNNHero.com 的教程,教你如何创建 custom DNN registration with the Google Recaptcha。它包括一个视频和代码项目。
查看我的代码,我在我的 ascx 中包含了公钥和私钥的属性,但具有虚拟值:
<googleCaptcha:RecaptchaControl ID="ctlRecaptcha" runat="server" PublicKey="your_public_key" PrivateKey="your_private_key"/>
我像您在 Page_Load 活动中那样设置了属性值。这对我有用。尝试一下,如果仍然抛出错误,请发表评论。
当我尝试在代码隐藏中动态分配 Public 和私钥时,加载 Google Recaptcha 控件时遇到问题。它在简单的 ASP.Net 网站上工作正常,但当我将它集成到 DNN 模块中时它不起作用。
错误消息: reCAPTCHA 需要配置 public 和私钥。
堆栈跟踪:
DotNetNuke.Services.Exceptions.PageLoadException: reCAPTCHA needs to be configured with a public & private key. ---> System.ApplicationException: reCAPTCHA needs to be configured with a public & private key. at Recaptcha.RecaptchaControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at DotNetNuke.UI.Modules.ModuleHost.InjectModuleContent(Control content) at DotNetNuke.UI.Modules.ModuleHost.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
标记:
<googleCaptcha:RecaptchaControl ID="ctlRecaptcha" runat="server" />
代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
ctlRecaptcha.PublicKey = "xyz";
ctlRecaptcha.PrivateKey = "abc";
}
我实际上有一个关于 DNNHero.com 的教程,教你如何创建 custom DNN registration with the Google Recaptcha。它包括一个视频和代码项目。
查看我的代码,我在我的 ascx 中包含了公钥和私钥的属性,但具有虚拟值:
<googleCaptcha:RecaptchaControl ID="ctlRecaptcha" runat="server" PublicKey="your_public_key" PrivateKey="your_private_key"/>
我像您在 Page_Load 活动中那样设置了属性值。这对我有用。尝试一下,如果仍然抛出错误,请发表评论。