Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Form .NET Viewstate Eventvalidation _Viewstate _Eventvalidation click fireevent No Navigate
This website has been updated to .NET and now this process does not work and the Website acts like it never received the POST.
The only difference I can see between the Forms are that .NET web pages include hidden fields __VIEWSTATE, __EVENTVALIDATION, __EVENTARGUMENT & __EVENTTARGET.
Fields __VIEWSTATE and __EVENTVALIDATION have values embedded in the HTML Form. So I first read the HTML Form into a File and read this files to extract the Values for these Fields and then include them in the form POST but the Website does nothing with the POST which implies the POST is being dropped as invalid.
The Login page works when manually accessed by IE or FireFox but I have not tried using the IE Object as I already had a working extender version so was hoping this method would still work. The Page designer added nothing to the Page creation these new hidden fields where added by the .NET development tool and his code does not explicitly check these POST values yet the other POST Value check code is never being called then a POST is sent from the Extender.
There is no JSESSIONID reference in the HTML and the designer did not request JSON but again this may be something the .NET development tools has added?
Try modifying your code to use the IE object instead. I believe this des support and work with the __Viewstate __Eventvalidation fields.
;*************************************************************************** ;** EODDATA Auto-Login and download ;** Logs into your EODDATA account online and attempts to download data. ;** ;** Ensure that you are signed-out of EODDATA before running! ;** Avoid use of Navigate method or __viewstate is lost! ;** Method used for Click can change based on IE versions/Settings? ;** ;** Developer: Deana Falk 2014.04.11 ;*************************************************************************** ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; Ensure that you are signed-out of EODDATA before running ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #DefineFunction udfIEPageLoadWait( objIE ) ; Wait for webpage to load While !(objIE.readyState == 'complete' || objIE.readyState == 4 ) TimeDelay(0.1) EndWhile While !(objIE.document.readyState == 'complete' || objIE.document.readyState == 4 ) TimeDelay(0.1) EndWhile Return 1 #EndFunction #DefineFunction udfClick(oIE, oElement) ; Used Click button on IE 9 and newer oEvent = oIE.Document.createEvent("HTMLEvents") If oEvent oEvent.initEvent("click", @TRUE, @TRUE) oElement.dispatchEvent(oEvent) Else oElement.fireEvent("onclick") EndIf #EndFunction url = 'http://www.eoddata.com' EODData_Login = "soandso@blahblah.com" ; MODIFY TO FIT YOUR NEEDS EODData_Password = "****" ; MODIFY TO FIT YOUR NEEDS oIE = ObjectCreate('internetexplorer.application') oIE.visible = @true; oIE.navigate(url); udfIEPageLoadWait( oIE ) ; Wait for First element ( helps with timing ) While @TRUE oElement = oIE.Document.getElementById("ctl00_cph1_lg1_txtEmail") type = ObjectTypeGet(oElement) If type != 'NULL' Then Break EndWhile oElement.value = EODData_Login oElement = oIE.Document.getElementById("ctl00_cph1_lg1_txtPassword") oElement.value = EODData_Password ; Click button oElement = oIE.Document.getElementById("ctl00_cph1_lg1_btnLogin") ;oElement.Click ;or ; Click button on IE 9 and newer ; createEvent initEvent DispatchEvent ;oEvent = oIE.Document.createEvent("HTMLEvents") ;oEvent.initEvent("click", @TRUE, @TRUE) ;oElement.dispatchEvent(oEvent) udfClick(oIE, oElement) oEvent = 0 oElement = 0 udfIEPageLoadWait( oIE ) ; Click link to go to download section ; Use Click link method in stead of Navigate() because Navigates losses __ViewState logginn info LinksCollection = oIE.document.links ForEach link In LinksCollection Link_Href = StrTrim(link.href) Link_Exist = StrIndexNC(Link_Href, "download.aspx", 1, @FWDSCAN);!!!!!!! If Link_Exist == 0 Then Continue ; Click link udfClick(oIE, link) Next udfIEPageLoadWait( oIE ) ; Select Downlad Details While @TRUE oElement = oIE.document.getElementsByTagName("select") type = ObjectTypeGet(oElement) If type != 'NULL' Then Break TimeDelay(0.25) EndWhile oExchange = oElement.Item(0) ; select the exchange Select_ExchangePos = 20 ; Nasdaq oExchange.Options.Item(Select_ExchangePos).selected = @TRUE ; set the exchange oFormat= oIE.document.getElementsByTagName("select").item(1) ; Set the format Select_FormatPos = 1 oFormat.Options.item(Select_FormatPos).selected = @TRUE oIE.document.GetElementByid("ctl00_cph1_d1_chkAllSymbols").checked = 1 oIE.document.GetElementByid("ctl00_cph1_d1_chkAllSymbols").fireevent("onclick") ; Wait for Download button element element While @TRUE oElement = oIE.Document.getElementById("ctl00_cph1_d1_btnDownload") type = ObjectTypeGet(oElement) If type != 'NULL' Then Break EndWhile ; Click Download button element element udfClick(oIE, oElement) TimeDelay(3) SendKey( '{TAB 2}' ) SendKey( '{DOWN 2}' ) SendKey( '{ENTER}' ) oEvent = 0 oElement = 0 oSelect_Format = 0 oExchange = 0 oIE = 0 Exit
Article ID: W17624
Filename: Website Forms with Viewstate and Eventvalidation .txt
File Created: 2014:04:11:10:57:52
Last Updated: 2014:04:11:10:57:52