JMeter - Sending HTTP POST Request to an ASP.NET Web Site


In this article, I will try to explore what is necessary to send HTTP POST Request to an ASP.NET web site using JMeter (It is similar to sending POST data to any other web pages with little bit difference due to the way how ASP.NET handles post requests).

I will not explain how to use JMeter for load testing, because JMeter website explain it in detail, JMeter website even explain on how to send post request to server. Check this link if you want to send normal post request. Furthermore URL Rewriting explanation can be found in this link. What JMeter documentation does not cover is how to do it in ASP.NET web page.

If you send a normal HTTP POST Request to an ASP.NET Web page (as you might send to other web page), ASP.NET will set Request.HttpMethod as POST but will not set the attribute IsPostBack as true until you send __EVENTTARGET attribute in POST data.

Now we know that it is necessary to send __EVENTTARGET, but it might not be enough because if there is anything wrong with __EVENTTARGET value, an exception like this is thrown in System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey, NameValueCollection postCollection):

Exception Details: System.ArgumentException: Invalid postback or callback argument


To solve this issue, you may need to add <pages enableEventValidation="false"/> under <system.web> of web.config.

This must be sufficient to send a HTTP POST request to an ASP.NET page.

Reference

2 comments:

  1. Hi Ajit. Thanks for valuable information. However not every tester has possibility to reconfigure IIS for testing sake. In order to perform load testing on close-to-production environment correlation is required (the process of extracting dynamic mandatory parameters from previous request into JMeter Variables and passing them with next request). See ASP.NET Login Testing with JMeter guide for more details

    ReplyDelete
  2. I have passed the view state, event validation and eventtarget values in the post request but still the request appears as a get request while executing the script. What can be done?

    ReplyDelete