ASP.NET __VIEWSTATE param issue

Hi,
I recording a scenario. For example, i have a dropdown (a postback control). Select an item on drop down then display list of checkboxes (pa,pa1,pa2,pa3…). Set an checkbox item (e.g pa1 as below) to TRUE and click Submit. Recorder generate __VIEWSTATE param corresponding selected value on page:
.param("""__VIEWSTATE""", “”"/wEPDwUJLTc4NjUzMzc4D2QW…""")
.param(""“ctl00$PlaceHolderMain$dtlUsers$ctl00$ckbUser”"", “”“on”"")
.param(""“ctl00$PlaceHolderMain$dtlUsers$ctl00$hdnUser”"", “”“pa1"”")

The __VIEWSTATE contains selected items at that time. So server will recognise that pa1 items checked. If i change to other user:
.param(""“ctl00$PlaceHolderMain$dtlUsers$ctl00$hdnUser”"", “”“pa2"”")
and re-run the scenario, server still recognise pa1 instead of pa2. How to achieve this?

Thanks.

I guess that works just like JSF’s ViewState and that parameter is hidden somewhere in the response, probably a hidden form input or some javascript var. Use your browser to check out HTML and javascript sources.

Here’s what we suggest for JSF: https://github.com/excilys/gatling/wiki/Handling-JSF
Note that with current master, you can define common check on the HTTP protocol so you don’t have to redefine them for every request.

Thanks Stéphane,
I’m using Gatling 2.0.0-SNAPSHOT, i tried to use “import io.gatling.core.session.Expression” instead of “import com.excilys.ebi.gatling.core.session.EvaluatableString” and change to “Expression” as below:
val jsfViewStateCheck = regex("""=“javax.faces.ViewState” value="([^"]*)"""")
.saveAs(“viewState”)
def jsfGet(name: String, url: Expression) = http(name).get(url)
.check(jsfViewStateCheck)
def jsfPost(name: String, url: Expression) = http(name).post(url)
.param(“javax.faces.ViewState”, “${viewState}”)
.check(jsfViewStateCheck)

But it throw error:

type Expression takes type parameters
def jsfPost(name: String, url: Expression) = http(name).post(url)
^
type Expression takes type parameters
def jsfGet(name: String, url: Expression) = http(name).get(url)

Please give me your advice.

Thanks.

I changed url: Expression to url: String and it complied without error. But run the script, it throws error:
13:55:42.271 [WARN ] i.g.h.a.AsyncHandlerActor - Request ‘request_0 Redirect 2’ failed: regex(=“javax.faces.ViewState” value="([^"]*)").exists, found nothing
13:55:43.235 [ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘viewState’ is defined
13:55:43.303 [WARN ] i.g.h.a.AsyncHandlerActor - Request ‘request_2’ failed: status.in(200,304,201,202,203,204,205,206,207,208,209), but actually found 401
13:55:44.306 [ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘viewState’ is defined

Here is my script:
val scn = scenario(“ActivateUserForSCTrials”)
.exec(jsfGet(“request_0”, “/”))
.pause(1)
.exec( jsfPost(""“request_1"”", “”"/Login.aspx?ReturnUrl=%2f_layouts%2fAuthenticate.aspx%3fSource%3d%252F&Source=%2F""")
.headers(headers_1)
.param(""“ctl00$ScriptManager”"", “”“ctl00$PlaceHolderMain$UpdatePanel1|ctl00$PlaceHolderMain$login$btnLogin”"")
.param("""__EVENTTARGET""", “”"""")
.param("""__EVENTARGUMENT""", “”"""")
.param("""__VIEWSTATE""", “”"/wEPDwUKLTQxMDA1MjA1OGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFJGN0bDAwJFBsYWNlSG9sZGVyTWFpbiRsb2dpbiRidG5Mb2dpbsTiOZqV7j1tYObWvg/Pem8s/1Oo""")
.param("""__EVENTVALIDATION""", “”"/wEWBALQz5vfCgLE96mtBQLLtsPBAgK3yKTrDkoJLFGdjapv0ZpilTRMpM9uL3gP""")
.param(""“ctl00$PlaceHolderMain$login$UserName”"", “”“pa”"")
.param(""“ctl00$PlaceHolderMain$login$password”"", “”“111111*”"")
.param("""__spText1""", “”"""")
.param("""__spText2""", “”"""")
.param("""__ASYNCPOST""", “”“true”"")
.param(""“ctl00$PlaceHolderMain$login$btnLogin.x”"", “”"-705""")
.param(""“ctl00$PlaceHolderMain$login$btnLogin.y”"", “”"-332"""))
.exec(jsfGet(“request_2”, “/AfterLogin.aspx?ReturnUrl=%2F”))
.pause(1)
.exec( jsfPost(""“request_3"”", “”"/ATCAfterLogin.aspx?ReturnUrl=%2F""")
.headers(headers_3)
.param("""__EVENTTARGET""", “”"""")
.param("""__EVENTARGUMENT""", “”"""")
.param("""__VIEWSTATE""", “”"/wEPDwUKLTE2NzQ5NzE5NWRkZaNLRebq7wiAGMdFdufUsvWbt7Y=""")
.param("""__EVENTVALIDATION""", “”"/wEWAwLMqtLuBwKw+Y6zBgLX9v2YCsSAG5vbPH1tC/ii+8r99tmFtW/D""")
.param(""“ctl00$PlaceHolderMain$btnAgree”"", “”“I accept”"")
.param("""__spText1""", “”"""")
.param("""__spText2""", “”""""))
.pause(461 milliseconds)

I’m running asp.net site, do you have any example for using JSF to resolve “__VIEWSTATE” issue?

Thanks in advance.

JSF means Java Server Faces.
This sample demonstrates the concept, you have to adapt to the technology you use.

I can’t help with .Net, sorry.

Hi Stéphane,

So my case cannot be resolved? Could you please have any plan to resolve for Asp.net?

Thanks.

Except if Asp.net does some very weird thing such as computing this field in javascript on the client side (which I doubt as it has to match some key on the server, so it’s probably generated on the server and send to the client in the responses), it’s likely to be feasible.

Gatling, like all other stress tools, deal with HTTP, so it’s agnostic of the web technology.

What I mean is that I have no .Net skill, so you have a dig a bit by yourself, or hope someone else on this mailing list can help you.

Thank you so much, Stéphane.

Hi ,

Were you able to get a resolution to this ? I’m facing the same issue. Any pointers?