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,
// 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.
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
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:
"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.
No comments:
Post a Comment