1

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...

Abdelrahman ELGAMAL
  • 414
  • 2
  • 7
  • 15
  • Missing hidden fields is the most common problem with Visual Studio web testing. What this means is that the __EVENTVALIDATION field was missing from the previous response. This is usually because the previous request failed or had an unexpected response. So you should look for the problem in the previous request (or possibly even before that). A useful practice is to add Validation rules to every request so that you can be reasonably sure that the responses are what you expect. – agentnega Oct 06 '11 at 21:28

4 Answers4

3

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

Dan
  • 816
  • 9
  • 14
1

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

John
  • 434
  • 2
  • 20
0

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);
vlaku
  • 1,534
  • 2
  • 14
  • 27
0

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.

Abdelrahman ELGAMAL
  • 414
  • 2
  • 7
  • 15