title: How to use JMeter for load testing ASP.net web applications implementing viewstate
body: <p>I'm a .net developer having no prior experience in JMeter/Stress testing. I'm trying to load test the ASP.net website that I had developed using JMeter. The reason for using JMeter is that its an open source tool having lots of fame and credibility.<br>
  I referred to <a href="http://blog.technicallyworks.com/2009/06/load-testing-aspnet-sites-with-jmeter.html" rel="nofollow">this link</a> in order to take care of viewstate which is a typical feature of ASP.net. However my requirements are not that simple as stated there. I'm trying to load test my site by sending userid and password to log-in page and then test through other pages which are allowed to be browsed only if log-in is successful.</p>
  
  <p>The steps that I'm taking to achieve this are listed below.</p>
  
  <ol>
  <li>Create Http Proxy Server by selecting WorkBench > Add > Non-Test Elements.</li>
  <li>Changing the network settings in Firefox to the port defined in Http Proxy Server.</li>
  <li>Creating a <code>Thread Group</code> by selecting Test Plan > Add > Threads(Users) > Thread Group.</li>
  <li>Creating <code>HTTP Request Defaults</code> by selecting Thread Group > Add > Config Element > HTTP Request Defaults.</li>
  <li>(a) Entering IP for my remote server in <code>Server Name or IP:</code><br>
  (b) Entering the path to my log-in page as <code>/MyWebApplication/login.aspx</code></li>
  <li>Create <code>User Defined Variables</code> by selecting Thread Group > Add > Config Element > User Defined Variables.</li>
  <li><p>My login.aspx page is very simple, it takes userid and password from two text-boxes and match them in database and if successful, redirects them to LoginSuccess.aspx page.<br>
  My login.aspx has three server controls only, two <code>asp:TextBox</code> for receiving loginid and password and one <code>asp:Button</code> for checking them in db.<br>
  The id of them are <code>txtLogin</code>, <code>txtPassword</code>, <code>btnLogin</code> respectively.</p>
  
  <p>In User Defined variables (created in step 6), I've added admin and 123admin, which are real logins in db getting checked in login.aspx page and on success is redirecting to LoginSuccess.aspx page.</p>
  
  <p>User defined variables:</p>
  
  <pre><code>Name:          Value    Description
  login          admin    
  password       123admin 
  </code></pre></li>
  <li><p>I'm adding two Regular Expression Extractor by selecting Thread Group > Add > Post Processors > Regular Expression Extractor.</p></li>
  <li><p>I've renamed the 1st Regular Expression Extractor as <code>View State Extractor</code> and adding following data to them:</p>
  
  <pre><code>Reference Name: viewstate
  Regular Expression: name="__VIEWSTATE" id="__VIEWSTATE" value="(.+?)"
  Template:$1$
  Match No.(0 for Random): 1
  Default Value: ERROR
  </code></pre></li>
  <li><p>Similarly I've renamed the 2nd Regular Expression Extractor as <code>Event Validation Extractor</code> and adding following data to them:</p>
  
  <pre><code>Reference Name: eventValidation
  Regular Expression: name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="(.+?)"
  Template:$1$
  Match No.(0 for Random): 1
  Default Value: ERROR
  </code></pre></li>
  <li><p>In step 5 I added following data</p>
  
  <pre><code>Send Parameters With the Request:
      Name:             - Value
      txtLogin          - $(login)
      txtPassword       - $(password)
      __VIEWSTATE       - $(viewState)
      __EVENTVALIDATION - $(eventValidation)
  </code></pre></li>
  <li><p>Now I added HTTP Cookie Manager by selecting Thread Group > Add > Config Element > HTTP Cookie Manager.</p></li>
  <li><p>Now I added Recording Controller by selecting Thread Group > Add > Logic Controller > Recording Controller.</p></li>
  <li><p>I started HTTP Proxy Server and then using firefox entered the complete URL to my login.aspx page, entered admin and 123admin in the two text boxes and pressed the Login button and got redirected successfully on LoginSuccess.aspx. I stopped the HTTP Proxy Server and closed my firefox browser.</p></li>
  </ol>
  
  <p>Now I've saved the test plan (containing the recorded steps, just 2 steps here, 1 for login.aspx and another for LoginSuccess.aspx) and running the test and viewing the test result in View Result Tree which is returning 500 error from the server.</p>
  
  <p>I'm unable to determine what ingredient I'm missing here because of which I can't successfully use JMeter. I've only changed those values which are mentioned here and for everything that I didn't write here the values are default type like <code>No of thread:</code>.</p>