Partager via


CoreWebView2.CallDevToolsProtocolMethodForSessionAsync Method

Definition

Runs an asynchronous DevToolsProtocol method for a specific session of an attached target.

public System.Threading.Tasks.Task<string> CallDevToolsProtocolMethodForSessionAsync (string sessionId, string methodName, string parametersAsJson);
member this.CallDevToolsProtocolMethodForSessionAsync : string * string * string -> System.Threading.Tasks.Task<string>
Public Function CallDevToolsProtocolMethodForSessionAsync (sessionId As String, methodName As String, parametersAsJson As String) As Task(Of String)

Parameters

sessionId
String

The sessionId for an attached target. null or empty string is treated as the session for the default target for the top page.

methodName
String

The full name of the method in the format {domain}.{method}.

parametersAsJson
String

A JSON formatted string containing the parameters for the corresponding method.

Returns

A JSON string that represents the method's return object.

Remarks

There could be multiple DevToolsProtocol targets in a WebView. Besides the top level page, iframes from different origin and web workers are also separate targets. Attaching to these targets allows interaction with them. When the DevToolsProtocol is attached to a target, the connection is identified by a sessionId.

To use this API, you must set the flatten parameter to true when calling Target.attachToTarget or Target.setAutoAttachDevToolsProtocol method. Using Target.setAutoAttach is recommended as that would allow you to attach to dedicated worker targets, which are not discoverable via other APIs like Target.getTargets.

For more information about targets and sessions, navigate to Chrome DevTools Protocol - Target domain.

For more information about available methods, navigate to DevTools Protocol Viewer. The handler's Invoke method will be called when the method asynchronously completes. Invoke will be called with the method's return object as a JSON string.

Applies to