How to send one advanced special HTTP Request in JMeter to simulate a form submit to a C# Handler?

525 views Asked by At

I'm trying to send one HTTP request using JMeter, the problem is I don't know how to send the parameters.

I have my form in frontend in this way:

<form id="SampleForm" method="POST" action="MyHandler.ashx" enctype="multipart/form-data">
 ... 
 ....
 .....
</form>

I send this form to backend using: $("#SampleForm").submit()

And backend is built as following:

public class MyHandler: IHttpHandler, IRequiresSessionState {
    public void ProcessRequest(HttpContext context) {
        ...
        ...
        ...
        var PartOfRequest = context.Request.Form["myFormElement"];
        ...
        ...
        ...
    }
}

The problem is in this part: context.Request.Form. I can send the HTTP Request to the handler, but it fails because it does not find the content of context.

Backend is waiting for one HTTP CONTEXT but I don“t know how I can sent a context from JMeter or if it is possible.

2

There are 2 answers

0
uru917 On

Please share screenshot of your JMeter script. Without that I can only suggest recording the request with Fiddler to see how the parameters are sent.

0
Dmitri T On

The easiest way to build the correct HTTP Request in JMeter is just recording it. There are several approaches like:


If you need just a single request and consider recording the "overkill" - try the following changes in HTTP Request sampler

  1. Change method to POST
  2. Tick Use multipart/form-data for POST

JMeter multipart post