CoreWebView2.PostWebMessageAsJson(String) Method


Posts the specified webMessageAsJson to the top level document in this WebView.

public void PostWebMessageAsJson (string webMessageAsJson);
member this.PostWebMessageAsJson : string -> unit
Public Sub PostWebMessageAsJson (webMessageAsJson As String)



The web message to be posted to the top level document in this WebView.


Runs the message event of the of the top-level document. JavaScript in that document may subscribe and unsubscribe to the event using the following code:'message', handler)'message', handler)


The event args is an instance of MessageEvent. The IsWebMessageEnabled setting must be true or this method will fail with E_INVALIDARG. The event arg's data property of the event arg is the webMessageAsJson string parameter parsed as a JSON string into a JavaScript object. The event arg's source property of the event arg is a reference to the object. For information about sending messages from the HTML document in the WebView to the host, navigate to WebMessageReceived. The message is sent asynchronously. If a navigation occurs before the message is posted to the page, the message is not be sent.

Applies to

See also