请求失败:上下文参数“$HIDDEN1.__EVENTVALIDATION”在测试上下文中找不到

发布于 2024-12-07 12:15:54 字数 536 浏览 0 评论 0 原文

我正在寻找此问题的解决方案:

在运行自动网络测试时,我收到一个失败的请求,这是我找到的响应: 请求失败:在测试上下文中找不到上下文参数“$HIDDEN1.__EVENTVALIDATION” 我弄清楚隐藏字段应该从哪个请求中提取(在之前的请求中),其中(Hidden1)我在之前请求的提取规则中找到它,并且上下文参数名称的提取规则的值为1。

注意:我这次使用的是静态参数,HTTP状态是200。

在网上搜索后发现:http://blogs .msdn.com/b/slumley/archive/2007/04/10/how-to-debug-a-web-test.aspx 我未能在其中找到解决方案。

这个问题似乎很复杂,因为我已经保留了两天而没有任何答案!如果有人想了解更多信息,我 24/24 在线:) 非常感谢...

I'am looking for a solution to this problem :

While running my automatic web test I received a request failed and here you are the response I found :
Request failed: Context parameter '$HIDDEN1.__EVENTVALIDATION' not found in test context
I figured out which request the hidden field was suppose to be extracted from (In the request before), where the (Hidden1) I found it in the extraction rule of the before request and the extraction rule’s value for Context Parameter Name is 1.

Note: I am using a statics parameters for this time, and the HTTP state is 200.

After searching on the internet i found : http://blogs.msdn.com/b/slumley/archive/2007/04/10/how-to-debug-a-web-test.aspx where I failed to find my solution in it.

This question seems to be complicated cause i kept it since 2 days without having any answer ! If anybody wants to know more information, I am online 24/24 :) Thanks alot...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

慈悲佛祖 2024-12-14 12:15:54

我遇到了与您遇到的类似问题(我发现这个问题很老了,但我想我会发布一个解决方案,因为这是谷歌针对此问题的第一个结果)。

问题在于 __EventValidation 标记是浏览器最后呈现的内容之一,并且 VisualStudio 2008 Web 测试会在响应对象超过一定长度(我认为限制为 1.5MB)时截断响应对象。

您有三个选择:

  1. 问问自己为什么您的页面大小超过 1.5MB,是否有必要,特别是如果这是一个公共网站?
  2. 将 Web 测试中的变量 ResponseBodyCaptureLimit 设置为一个很大的值,单位以字节为单位,因此像 9,000,000 (9MB) 这样的值足以获取任何响应对象。请注意,这将对您的 Web 测试的内存使用产生影响,如果您将其用于任何负载/性能测试,那么这将意味着您的代理将需要更多内存。
  3. 重写 OnPreRender 方法将 __EventValidation 标记从页面底部移动到页面顶部。

希望能帮助任何面临类似问题的人。

~丹

I had a similar problem to what you were experiencing (I see that this question is very old, but I thought I would post a solution as this is the first result in google for this issue).

The problem is that the __EventValidation tag is one of the last things rendered by the browser and that VisualStudio 2008 web tests truncate the response object when it is over a certain length (I think the limit is 1.5MB).

You have three options:

  1. Ask yourself why your page is over 1.5MB in size and is it necessary, particularly if this is a public website?
  2. Set the variable ResponseBodyCaptureLimit in the web test to a massive value, the units are in bytes, so something like 9,000,000 (9MB) would big enough to get any response object. Just be aware that this will have an impact on the memory usage of your web test and if you are using this for any load/performance testing then that will mean your agents will need more memory.
  3. Override the OnPreRender method to move __EventValidation tag from the bottom of the page to the top of the page.

Hope that helps anyone facing similar issues.

~Dan

顾冷 2024-12-14 12:15:54

我遇到了类似的问题并且仍在解决它们。同时,此链接也可能有所帮助:

http://blogs.msdn.com/b/slumley/archive/2007/04/10/how-to-debug-a-web-test.aspx

I'm running into similar issues and still working through them. In the meantime, this link may be of help as well:

http://blogs.msdn.com/b/slumley/archive/2007/04/10/how-to-debug-a-web-test.aspx

拥抱影子 2024-12-14 12:15:54

解决方案是将所有 EnableEventValidation 属性更改为 true(这是默认值)。

但我的开放中最好的解决方案是使用Visualstudio 2010的VSTS,它比2008年的要好,两者之间确实发生了很大的演变。

The solution is to change all the EnableEventValidation attribute to true (which is the default value).

But the best solution in my openion is to use the VSTS of visualstudio 2010 , it is better than the that of 2008, really a big evolution happened between both of them.

草莓酥 2024-12-14 12:15:54

如果有人遇到这个问题并选择重写 Render 方法,这里有一个示例代码。

        var stringWriter = new System.IO.StringWriter();
        var htmlWriter = new HtmlTextWriter(stringWriter);
        base.Render(htmlWriter);

        var html = stringWriter.ToString();

        const string validationELement = "<input type=\"hidden\" name=\"__EVENTVALIDATION\"";
        const string hiddenDivName = "<div class=\"aspNetHidden\">";

        // Find event validation element.
        var startIndex = html.IndexOf(validationELement);
        if (startIndex >= 0)
        {
            var endIndex = html.IndexOf("/>", startIndex) + 2;

            // Cut event validation element.
            var input = html.Substring(startIndex, endIndex - startIndex);
            html = html.Remove(startIndex, endIndex - startIndex);

            // Paste element into hidden div.
            var hiddenDivStartIndex = html.IndexOf(hiddenDivName);
            html = html.Insert(hiddenDivStartIndex + hiddenDivName.Length, input);
        }

        writer.Write(html);

In case if someone would face this problem and choose to override Render method, here is a sample code.

        var stringWriter = new System.IO.StringWriter();
        var htmlWriter = new HtmlTextWriter(stringWriter);
        base.Render(htmlWriter);

        var html = stringWriter.ToString();

        const string validationELement = "<input type=\"hidden\" name=\"__EVENTVALIDATION\"";
        const string hiddenDivName = "<div class=\"aspNetHidden\">";

        // Find event validation element.
        var startIndex = html.IndexOf(validationELement);
        if (startIndex >= 0)
        {
            var endIndex = html.IndexOf("/>", startIndex) + 2;

            // Cut event validation element.
            var input = html.Substring(startIndex, endIndex - startIndex);
            html = html.Remove(startIndex, endIndex - startIndex);

            // Paste element into hidden div.
            var hiddenDivStartIndex = html.IndexOf(hiddenDivName);
            html = html.Insert(hiddenDivStartIndex + hiddenDivName.Length, input);
        }

        writer.Write(html);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文