interface ICoreWebView2Environment2
interface ICoreWebView2Environment2
: public ICoreWebView2Environment
A continuation of the ICoreWebView2Environment interface.
Summary
Members | Descriptions |
---|---|
CreateWebResourceRequest | Create a new web resource request object. |
Applies to
Product | Introduced |
---|---|
WebView2 Win32 | 1.0.705.50 |
WebView2 Win32 Prerelease | 1.0.721 |
Members
CreateWebResourceRequest
Create a new web resource request object.
public HRESULT CreateWebResourceRequest(LPCWSTR uri, LPCWSTR method, IStream * postData, LPCWSTR headers, ICoreWebView2WebResourceRequest ** request)
URI parameter must be absolute URI. The headers string is the raw request header string delimited by CRLF (optional in last header). It's also possible to create this object with null headers string and then use the ICoreWebView2HttpRequestHeaders to construct the headers line by line. For information on other parameters see ICoreWebView2WebResourceRequest.
wil::com_ptr<ICoreWebView2Environment2> webviewEnvironment2;
CHECK_FAILURE(appWindow->GetWebViewEnvironment()->QueryInterface(
IID_PPV_ARGS(&webviewEnvironment2)));
wil::com_ptr<ICoreWebView2WebResourceRequest> webResourceRequest;
wil::com_ptr<IStream> postDataStream = SHCreateMemStream(
reinterpret_cast<const BYTE*>(postDataBytes.get()), sizeNeededForMultiByte);
// This is acts as a form submit to https://www.w3schools.com/action_page.php
CHECK_FAILURE(webviewEnvironment2->CreateWebResourceRequest(
L"https://www.w3schools.com/action_page.php", L"POST", postDataStream.get(),
L"Content-Type: application/x-www-form-urlencoded", &webResourceRequest));
wil::com_ptr<ICoreWebView2_2> webview2;
CHECK_FAILURE(m_appWindow->GetWebView()->QueryInterface(IID_PPV_ARGS(&webview2)));
CHECK_FAILURE(webview2->NavigateWithWebResourceRequest(webResourceRequest.get()));
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈