WebClient.Post being ignore

LiamLiam Posts: 3
edited June 1, 2005 5:53AM in ANTS Load
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).

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hello Liam,

    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.
  • Thanks for the quick response. I couldn't see the error you mentioned recorded anywhere. Also, I manually put the extra GET into the script, still didn't seem to make any difference. I am a bit bemused as to why I can step through the code correctly whilst recording the script, but playing it back dosn't work - does this mean the scripting within ANTS is broken? We are in the process of creating 100s of scripts, I don't think manually editting them is going to go down very well. I'm under quite a bit of pressure to get this going otherwise we'll have to look at alternatives.

    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).
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Anywhere before the WebClient.ViewState would be grand!
    BeginPage("http://localhost/CIMSWebUI/Classification/CIMSS00180.aspx") 
    WebClient.Protocol= "HTTP/1.1"
    WebClient.Get("http://localhost/CIMSWebUI/Classification/CIMSS00180.aspx") 
    EndPage("http://localhost/CIMSWebUI/Classification/CIMSS00180.aspx") 
    
    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). 
    
This discussion has been closed.