Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

FormPostHttpBody Class

 

Represents an HTML form post body with a collection of form parameters.

Namespace:   Microsoft.VisualStudio.TestTools.WebTesting
Assembly:  Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)

System.Object
  Microsoft.VisualStudio.TestTools.WebTesting.FormPostHttpBody

[SerializableAttribute]
public class FormPostHttpBody : IHttpBody, ICloneable

NameDescription
System_CAPS_pubmethodFormPostHttpBody()

Initializes a new instance of the FormPostHttpBody class.

NameDescription
System_CAPS_pubpropertyContentType

Gets a value that indicates the content type of the data being sent.

System_CAPS_pubpropertyFormPostParameters

Gets the list of FormPostParameters included in this FormPostHttpBody.

NameDescription
System_CAPS_pubmethodClone()

Returns a deep copy of the FormPostHttpBody.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodWriteHttpBody(WebTestRequest, Stream)

Writes the HTTP body stream.

This type is a container for information that is used by the POST method for submitting data back to the server in a HTTP body. This class can be serialized.

Legacy Code Example

The following code examples show how a FormPostHttpBody adds form post parameters to the body of the WebTestRequest.

namespace TestProject1
{
    using System;
    using System.Collections.Generic;
    using Microsoft.VisualStudio.TestTools.WebTesting;
    using Microsoft.VisualStudio.TestTools.WebTesting.Rules;

    public class MyCodedWebTest : WebTest
    {
        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest request1 = new WebTestRequest("http://localhost/MyWebSite");
            request1.ThinkTime = 14;
            ExtractHiddenFields rule1 = new ExtractHiddenFields();
            rule1.ContextParameterName = "1";
            request1.ExtractValues += new EventHandler<ExtractionEventArgs>(rule1.Extract);
            yield return request1;

            WebTestRequest request2 = new WebTestRequest("http://localhost/MyWebSite/Default.aspx");
            request2.Method = "POST";
            FormPostHttpBody request2Body = new FormPostHttpBody();
            request2Body.FormPostParameters.Add("__VIEWSTATE", "{{$HIDDEN1.__VIEWSTATE}}");
            request2Body.FormPostParameters.Add("Button1", "Button");
            request2Body.FormPostParameters.Add("TextBox1", "text entered");
            request2.Body = request2Body;
            yield return request2;
        }
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: