I was trying to make LINK FINDER and facing 2 issue
Issue 1 (Resolved) :: Unable to get url of redirected page
This was resolved REFERNCE LINK by using WinHttp.WinHttpRequest.5.1
Issue 2 (Unsolved) :: unable to use WinHttp.WinHttpRequest.5.1 object EVENTS Or no callback to asynchronous request
Synchronous request code
Set req = CreateObject("WinHttp.WinHttpRequest.5.1")
req.open "GET", url, FALSE
req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.send PostData
This is working fine but if I have multuple request , then its taking to much time.
I have tried following Asynchronous request code but get error
Set req = CreateObject("WinHttp.WinHttpRequest.5.1")
req.open "GET", url, TRUE
req.OnReadyStateChange = GetRef("req_OnReadyStateChange")
req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.send PostData
Function req_OnReadyStateChange
' do something
End Function
Code 1
Set req = CreateObject("WinHttp.WinHttpRequest.5.1","req_")
req.open "GET", url, TRUE
Function req__OnResponseFinished
' do something
End Function
req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.send PostData
ERROR - The remote server machine does not exist or is unavailable: 'CreateObject'
Code 2
Set req = CreateObject("WinHttp.WinHttpRequest.5.1")
req.open "GET", url, TRUE
req.OnResponseFinished = GetRef("req_OnResponseFinished")
Function req_OnResponseFinished
' do something
End Function
req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.send PostData
ERROR : Object doesn't support this property or method: 'req.OnResponseFinished
Code 3
Set req = CreateObject("WinHttp.WinHttpRequest.5.1")
req.open "GET", url, TRUE
req.OnReadyStateChange = GetRef("req_OnReadyStateChange")
req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.send PostData
Function req_OnReadyStateChange
' do something
End Function
In microsoft documentation, they have referred WinHttp.WinHttpRequest.5.1 have 4 event.
- OnError
- OnResponseDataAvailable
- OnResponseFinished
- OnResponseStart
But i didn't got example of how to use this event, nor i am able to use these event in ASP.
Hope for quick response...