{"id":1684,"date":"2011-02-26T10:56:39","date_gmt":"2011-02-26T05:26:39","guid":{"rendered":"https:\/\/www.qadit.com\/blog\/?p=1684"},"modified":"2011-03-07T12:58:10","modified_gmt":"2011-03-07T07:28:10","slug":"load-testing-asp-net-web-applications-using-jmeter","status":"publish","type":"post","link":"https:\/\/qadit.com\/blog\/load-testing-asp-net-web-applications-using-jmeter\/","title":{"rendered":"Load Testing ASP.NET Web Applications using Jmeter"},"content":{"rendered":"<p>People do not like slow responses on web sites. It just drives them away. If you would like to know how fast\/slow your web site is when 100 or 1000 users access it, what you are attempting to is labelled &#8216;load testing&#8217;. There are many commercial and free tools that do the job for web applications running on Java, ASP.NET, PHP etc. We will specifically look at testing ASP.NET applications using the open source tool called Jmeter. <\/p>\n<p>&nbsp; <\/p>\n<p>\n<!--more--><br \/>\nApache JMeter  is open source software, a 100% pure Java desktop application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions. <\/p>\n<p>&nbsp; <\/p>\n<p>\nApache JMeter may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server\/script\/object behavior under heavy concurrent load. <\/p>\n<p>&nbsp; <\/p>\n<p>\nIn fact, Jmeter can load and performance test many different server types:<\/p>\n<p>&nbsp; <\/p>\n<p>\n    * Web &#8211; HTTP, HTTPS<br \/>\n    * SOAP<br \/>\n    * Database via JDBC<br \/>\n    * LDAP<br \/>\n    * JMS<br \/>\n    * Mail &#8211; POP3(S) and IMAP(S)<\/p>\n<p>&nbsp; <\/p>\n<p>\nSo, as mentioned above, let us look at how to load test our ASP.NET applications. <\/p>\n<p>&nbsp; <\/p>\n<p>\nLet us assume that the ASP.NET web application that we are testing uses something called &#8216;postback&#8217; and has enabled the ASP.NET security mechanisms of event validation and request validation. <\/p>\n<p>&nbsp; <\/p>\n<p>\nIn very simple terms, when ever a postback is used, the page is submitted to itself &amp;  the server sends a set of hidden variables (that are considerably long ) to the user eg. __VIEWSTATE &amp; __EVENTVALIDATION. <\/p>\n<p>&nbsp; <\/p>\n<p>\nHere are a few notes on postback requests:<\/p>\n<p>&nbsp; <\/p>\n<p>\n    * The current value of every control on a Web Form is contained in the postback request. This is referred to as the Post Data<br \/>\n    * The content of the ViewState is also contained in the Post Data. ViewState holds the original property values of every control on a Web Form &#8211; before the user made any changes<br \/>\n    * If a postback was caused, for example, by a button click, Post Data is used to identify the button that caused the postback<\/p>\n<p>&nbsp; <\/p>\n<p>\nWhen the user submits such a page with event validation enabled, the server checks to see if it has received back the variables that it sent for eg. the __VIEWSTATE and __EVENTVALIDATION<\/p>\n<p>&nbsp; <\/p>\n<p>\nSo, let us see how to load test in this scenario.<\/p>\n<p>&nbsp; <\/p>\n<p>\nI am leaving out basic installation &amp; use of Jmeter as there are many articles covering it. One of the good ones with a very detailed explanation for basic testing can be found here https:\/\/www.roseindia.net\/jmeter\/using-jmeter.shtml<\/p>\n<p>&nbsp; <\/p>\n<p>\nOpen Jmeter. Add a thread group. Add a HTTP request to this thread group (Right click the thread group -&gt; add -&gt; sampler -&gt; HTTP Request). Let us assume this  page, let&#8217;s say login.aspx sets the viewstate and eventvalidation parameter. You need to extract the 2 parameters and pass it on as part of your next request. You need to explicitly do this when using a load test tool but obviously, when browsing the site, all this happens in the background and is taken care of by your browser. <\/p>\n<p>&nbsp; <\/p>\n<p>\nTo extract the viewstate and eventvalidation parameters:<br \/>\n1. right click on the HTTP request of the login page (the page that served you the 2 variables)<br \/>\n2. Add -&gt; Post Processor -&gt; Regular Expression Extractor<\/p>\n<p>&nbsp; <\/p>\n<p>\nFill up as follows:<br \/>\nReference name: viewstate1<br \/>\nRegular Expression: id=&#8221;__VIEWSTATE&#8221; value=&#8221;(.+?)&#8221;<br \/>\nTemplate: $1$<br \/>\nMatch no: 1<br \/>\nDefault Value: False<\/p>\n<p>&nbsp; <\/p>\n<p>\nWhat happens when you do this:<br \/>\n&#8211; The login page is served<br \/>\n&#8211; The post-processor (which aptly goes to work &#8216;post&#8217; the serving of the page) goes to work and the value of __VIEWSTATE is now stored in the variable viewstate1 <\/p>\n<p>&nbsp; <\/p>\n<p>\nAfter you login, let us say there is a page &#8216;change password&#8217; and you want to click on this and change your password. The viewstate parameter is to be sent to the server as part of this request. So, do the following:<br \/>\n&#8211; Add a HTTP request<br \/>\n&#8211; In the Box &#8220;Send parameters with request&#8221;, in addition to the regular POST data that you want to send, add the following<br \/>\n\t&#8211; __VIEWSTATE = ${viewstate1} where viewstate1 is the reference name set as above<\/p>\n<p>&nbsp; <\/p>\n<p>\nThe important thing to note is that every time a viewstate (or any other variable) is to be extracted and sent to the server, the above process has to be repeated. Let&#8217;s say you are testing the shopping cart. You define a series of requests that form the logical transaction. Along with every request in this series, you have to send the viewstate extracted in the previous request. <\/p>\n<p>&nbsp; <\/p>\n<p>\nFor eg. login.aspx -&gt; extract viewstate1<br \/>\n        select &#8220;buy 4GB pen drive&#8221; -&gt; send viewstate1 &amp; extract viewstate2<br \/>\n        select &#8220;buy book&#8221; -&gt; send viewstate2, extract viewstate3<br \/>\n\tcheckout -&gt; send viewstate3 &amp; extract viewstate4<br \/>\n\tand so on&#8230;<\/p>\n<p>&nbsp; <\/p>\n<p>\nTo view the results, you can right click on the thread group -&gt; Add -&gt; Listener -&gt; View Results Tree or any of the other options available for viewing results. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>People do not like slow responses on web sites. It just drives them away. If you would like to know how fast\/slow your web site is when 100 or 1000 users access it, what you are attempting to is labelled &#8216;load testing&#8217;. There are many commercial and free tools that do the job for web &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/qadit.com\/blog\/load-testing-asp-net-web-applications-using-jmeter\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Load Testing ASP.NET Web Applications using Jmeter&#8221;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[78,109],"tags":[],"class_list":["post-1684","post","type-post","status-publish","format-standard","hentry","category-information-technology","category-website-security"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9AH7Q-ra","_links":{"self":[{"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/posts\/1684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/comments?post=1684"}],"version-history":[{"count":0,"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/posts\/1684\/revisions"}],"wp:attachment":[{"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/media?parent=1684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/categories?post=1684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qadit.com\/blog\/wp-json\/wp\/v2\/tags?post=1684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}