AjaxControlToolkit NoBotState总是InvalidBadResponse

编程入门 行业动态 更新时间:2024-10-14 12:20:12
本文介绍了AjaxControlToolkit NoBotState总是InvalidBadResponse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想实现AjaxControlToolkit NoBot但我总是得到假的IsValid()办法(状态值始终 InvalidBadResponse )。 ?我失去了一些东西在这里。

I am trying to implement AjaxControlToolkit NoBot but I always get false from IsValid() method (the state value is always InvalidBadResponse). Am I missing something here?

ASCX代码:

// buttons, textboxes etc. <asp:NoBot ID="NoBot1" runat="server" CutoffMaximumInstances="5" CutoffWindowSeconds="60" ResponseMinimumDelaySeconds="2" />

后面的代码:

Code behind:

protected void Button1_Click(object sender, EventArgs e) { AjaxControlToolkit.NoBotState state; if (!NoBot1.IsValid(out state)) { Page page = HttpContext.Current.Handler as Page; ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + " BOT " + "');", true); } else { ...} }

更奇怪的是这样的:我为登录输入数据并点击按钮的ASP。 NoBot状态是 InvalidBadResponse 和失败。但是,后来我在浏览器的刷新按钮,点击它要求我重新发送请求,我说OK,现在的状态是有效的!为什么呢?

Far more weird is this: I enter data for login and click on asp button. NoBot state is InvalidBadResponse and it fails. But, then I click on browser's refresh button it asks me to resend request I say ok and now state is valid! Why?

推荐答案

我所知道的唯一的原因,你会得到一个 InvalidBadResponse 在 NoBot 控制,如果你有浏览器的JavaScript禁用。该文档页面指出,由 NoBot 是

The only reason I know of that you'll get an "InvalidBadResponse" from the NoBot control is if you have javascript disabled in your browser. The documentation page states that one of the techniques used by NoBot is

强制客户端的浏览器进行配置JavaScript 计算和验证结果作为回发的一部分。 (例如:在计算可以是一个简单的数字,或者也可以包括用于加入保证一个浏览器所涉及的DOM $ B $二)

Forcing the client's browser to perform a configurable JavaScript calculation and verifying the result as part of the postback. (Ex: the calculation may be a simple numeric one, or may also involve the DOM for added assurance that a browser is involved)

这是 InvalidBadRespone 消息意味着JavaScript的没有得到(也是从上面的链接)执行:

An "InvalidBadRespone" message means that the javascript did not get executed (also from the link above):

InvalidBadResponse:的无效响应这一挑战暗示的挑战脚本无法运行。

InvalidBadResponse: An invalid response was provided to the challenge suggesting the challenge script was not run

我会仔细检查浏览器设置。我已经在我的浏览器(只是为了确保)禁用JavaScript和尝试文档页的示例测试这一点。

I would double check your browser settings. I've tested this by disabling javascript in my browser (just to make sure) and trying the example on the documentation page.

您可以使用自定义计算 OnGenerateChallengeAndResponse 属性来指定事件处理程序。我好实现一个这样的事件处理程序的例子是这样的(代码信贷的这个帖子):

You can customize the calculation using the OnGenerateChallengeAndResponse attribute to specify an Event Handler. I good example of implementing one such event handler is this (code credit to this post):

protected void PageNoBot_GenerateChallengeAndResponse(object sender, AjaxControlToolkit.NoBotEventArgs e) { Random r = new Random(); int iFirst = r.Next(100); int iSecond = r.Next(100); e.ChallengeScript = String.Format("eval('{0}+{1}')", iFirst, iSecond); e.RequiredResponse = Convert.ToString(iFirst + iSecond); }

更多推荐

AjaxControlToolkit NoBotState总是InvalidBadResponse

本文发布于:2023-11-24 23:50:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627417.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:AjaxControlToolkit   NoBotState   InvalidBadResponse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!