Archive for the ‘Correlations’ Category.

Scripting for Microsoft ASP.NET VIEWSTATE in VuGen LoadRunner

ASP.NET web applications maintain state of data by passing hidden _VIEWSTATE field encoded using base64 algorithm. The state of the page is restored based on the VIEWSTATE. If on the client side, the value of textbox has been changed, VIEWSTATE will now have the new value. (Obviously, this stage does not happen when the page is requested for the first time).

Let’s see how Web Applications developer store objects in VIEWSTATE,

1
2
3
4
5
6
// Storing a Customer object in view state.
Customer cust = new Customer ("Dilip", "Kutarmare");
ViewState["CurrentCustomer"] = cust;

// Retrieve a student from view state.
Customer cust = (Customer) ViewState["CurrentCustomer"];

Now we will see how to capture and replace VIEWSTATE in a recorded script,

1. First set the html parameter length to maximum so that it can store VIEWSTATE, You can adjust this number after examining the captured value.

1
web_set_max_html_param_len("50000");

2. Capture the VIEWSTATE value when it is returned from the server using web_reg_save_param() function

1
web_reg_save_param("MyViewState","LB=\"__VIEWSTATE\" value=\"","RB=\"","ORD=ALL",LAST);

3. Substitute the captured value with the parameter name in which you captured the VIEWSTATE:

1
"Name=__VIEWSTATE", "value={MyViewState}", ENDITEM,

4. Run the script (with enabled advanced log) in VuGen and verify that the correlation function is capturing the right value.