Contents - Index - Top


NavigateWithWebResourceRequestSync

Interface AntView 

 

Type: Method

Parameters: String uri String method String postData String headers Boolean *IsSuccess TxWebErrorStatus *WebErrorStatus

Returns: Integer

 

 

Use this navigation to create a custom navigation.

This method internally creates a custom WebResourceRequest object that is then passed to the uri on your behalf.

 

uri has the full URL of the resource you want to access, including the protocol.

Example:

uri = "https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending?sort=dont-sort"

 

Allowed methods: "GET"/"POST"

 

postData will only be send if the method is "POST" and the url scheme starts with either http or https.

If you need to pass form data in the postData then you add it as a standard url encoded scheme. AntView does not url encode the data for you.

Example in DataFlex:

 Move "https://tryphp.w3schools.com/demo/demo_form_validation_escapechar.php" to sURL

 Move "Content-Type: application/x-www-form-urlencoded\r\n" to sHeaders

 Move "name=Pete&email=test@example.com&website=www.example.com&comment=This%20is%20some%20comment." to sText

 Send ComNavigateWithWebResourceRequest of oEdgeWebBrowser sURL "POST" sText sHeaders

 

headers : You can add multiple headers,  the way to seperate those is with carriage return, linefeed written as "\r\n"

Example:

 Headers = "Referer: https://example.com/\r\nDnt: 1\r\n"

or 

 Headers = "Content-Type: multipart/form-data\r\n"

 

The navigation process will raise a number of events, starting with the OnNavigationStarting event.

You can see the results of the request in the OnNavigationCompleted event.

Alternatively you can look at the - pass by reference - variables IsSuccess and WebErrorStatus.

IsSuccess is True when the document was correctly loaded, if IsSuccess returns false then you can inspect WebErrorStatus for the reason (see TxWebErrorStatus for details)

 

The function itself returns the following values:

  0 if no errors. 

  21 function is already running (can only run one at a time)

  22 function timed out

  25 Trying to run a synchronous method from within a WebView2 event

 

If navigating the passed URL takes more than 5 seconds, you might want to adjust the time out via SynchronousTimeOut to something else. As SynchronousTimeOut has a default for the AntView interface of 5 seconds.

 

 

This is the Synchronous alternative of the NavigateWithWebResourceRequest method.

As the function wraps the async bits, you cannot have the asynchronous variant running when you call this.

Beware that you cannot issue a synchronous call from within an AntView event, with the exception being the OnCreate event.

 

Introduced in AntView release 1.1.270

 


AntView - The MS Edge WebView2 ActiveX control Date last changed: 09/30/2024