1

In a particular Visual Studio Web Performance Test I'm sending a set of requests asynchronously. I'd like to find a way to access the response from every request in this set.

To send the requests asynchronously I'm using the DependentRequests property of the WebTestRequest.

My code to implement the enumerator in the test's WebTest class and send out the requests looks like:

public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
    WebTestRequest request = new WebTestRequest("http://url1");
    request.DependentRequests.Add(new WebTestRequest("http://url2");
    request.DependentRequests.Add(new WebTestRequest("http://url3");

    yield return request;

I can get the response body from http://url1 using the LastResponse property in the WebTest class .

    string bodyStringFromURL1 = LastResponse.BodyString;
}

How can I get the response bodies from http://url2 and http://url3?

John O.
  • 708
  • 5
  • 9
  • Can you use a `PostRequest()` method in a web test request plugin? That would not directly relate request to response, although the plugin should be able to see the request URL as well as the response body. – AdrianHHH Nov 09 '14 at 08:37

1 Answers1

1

I was able to do this by attaching an event handler to the PostRequest event of the dependent request and getting the data from e.Response.BodyString.

James Bender
  • 1,175
  • 1
  • 11
  • 22