WebClient.Post being ignore
I have created a script that I am using for recording data entry. There are 3 pages involved in the data entry process, a list, a record type selection, and a data entry page. The script recorded perfectly. When I run the script, and debug on my server, one of the calls to Post is never received by the server...the line highlighted in red is the one that never seems to execute.....instead it skips straight to the final page in the series.....anyone got any ideas?
BeginPage("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
WebClient.HttpRequest.ContentType = "application/x-www-form-urlencoded"
WebClient.HttpRequest.AddPostData("__EVENTTARGET", "", False)
WebClient.HttpRequest.AddPostData("__EVENTARGUMENT", "", False)
WebClient.HttpRequest.AddPostData("__VIEWSTATE", WebClient.ViewState, False)
WebClient.HttpRequest.AddPostData("RadioButtonList_ClassificationMode", "Reclassification", False)
WebClient.HttpRequest.AddPostData("Buton_Next", "Next", False)
WebClient.POST("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX") WebClient.HttpRequest.ContentType = Nothing
WebClient.GET("http://localhost/CIMSWebUI/Classification/CIMSS00179.aspx?mode=reclassification")
WebClient.HttpRequest.Pragma = Nothing
WebClient.GET("http://localhost/webctrl_client/1_0/tabstrip.htc")
WebClient.GET("http://localhost/webctrl_client/1_0/tabstrip.htc")
WebClient.GET("http://localhost/CIMSWebUI/Classification/null")
EndPage("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
' End of page 7 contains 5 request(s).
BeginPage("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
WebClient.HttpRequest.ContentType = "application/x-www-form-urlencoded"
WebClient.HttpRequest.AddPostData("__EVENTTARGET", "", False)
WebClient.HttpRequest.AddPostData("__EVENTARGUMENT", "", False)
WebClient.HttpRequest.AddPostData("__VIEWSTATE", WebClient.ViewState, False)
WebClient.HttpRequest.AddPostData("RadioButtonList_ClassificationMode", "Reclassification", False)
WebClient.HttpRequest.AddPostData("Buton_Next", "Next", False)
WebClient.POST("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX") WebClient.HttpRequest.ContentType = Nothing
WebClient.GET("http://localhost/CIMSWebUI/Classification/CIMSS00179.aspx?mode=reclassification")
WebClient.HttpRequest.Pragma = Nothing
WebClient.GET("http://localhost/webctrl_client/1_0/tabstrip.htc")
WebClient.GET("http://localhost/webctrl_client/1_0/tabstrip.htc")
WebClient.GET("http://localhost/CIMSWebUI/Classification/null")
EndPage("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
' End of page 7 contains 5 request(s).
This discussion has been closed.
Comments
I'd imagine that if you look at your W3svc logs on the server, you'll probably see a 500 error, and if you captured the content of the web response, an Invalid Viewstate error.
This is a common problem with ASP .NET. You have to make a GET request to the page before POSTing to it. This way, ANTS Load will properly populate the Webclient.ViewState property so that it can be posted back to the server with the POST operation.
Please let us know if this solves the problem.
I've included more of the script below, it did have a GET in it in the previous section...but as I said, even with an extra one nothing different happened....could you point out the correct place to insert it?
Sleep(1859)
BeginPage("http://localhost/CIMSWebUI/Classification/CIMSS00180.aspx")
WebClient.HttpRequest.Pragma = "no-cache"
WebClient.HttpRequest.ContentType = "application/x-www-form-urlencoded"
WebClient.HttpRequest.AddPostData("__EVENTTARGET", "", False)
WebClient.HttpRequest.AddPostData("__EVENTARGUMENT", "", False)
WebClient.HttpRequest.AddPostData("__VIEWSTATE", WebClient.ViewState, False)
WebClient.HttpRequest.AddPostData("UCDataGrid1%3AbtnAdd.x", "6", False)
WebClient.HttpRequest.AddPostData("UCDataGrid1%3AbtnAdd.y", "1", False)
WebClient.POST("http://localhost/CIMSWebUI/Classification/CIMSS00180.aspx")
WebClient.HttpRequest.ContentType = Nothing
WebClient.GET("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
EndPage("http://localhost/CIMSWebUI/Classification/CIMSS00180.aspx")
' End of page 6 contains 2 request(s).
Sleep(2234)
WebClient.Get("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
BeginPage("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
WebClient.HttpRequest.ContentType = "application/x-www-form-urlencoded"
WebClient.HttpRequest.AddPostData("__EVENTTARGET", "", False)
WebClient.HttpRequest.AddPostData("__EVENTARGUMENT", "", False)
WebClient.HttpRequest.AddPostData("__VIEWSTATE", WebClient.ViewState, False)
WebClient.HttpRequest.AddPostData("RadioButtonList_ClassificationMode", "Reclassification", False)
WebClient.HttpRequest.AddPostData("Buton_Next", "Next", False)
WebClient.POST("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
WebClient.HttpRequest.ContentType = Nothing
WebClient.GET("http://localhost/CIMSWebUI/Classification/CIMSS00179.aspx?mode=reclassification")
WebClient.HttpRequest.Pragma = Nothing
WebClient.GET("http://localhost/webctrl_client/1_0/tabstrip.htc")
WebClient.GET("http://localhost/webctrl_client/1_0/tabstrip.htc")
WebClient.GET("http://localhost/CIMSWebUI/Classification/null")
EndPage("http://localhost/CIMSWebUI/Classification/CIMSS00181.ASPX")
' End of page 7 contains 5 request(s).