{"id":4162,"date":"2021-01-27T23:03:50","date_gmt":"2021-01-27T21:03:50","guid":{"rendered":"https:\/\/mariusbancila.ro\/blog\/?p=4162"},"modified":"2023-04-05T08:06:07","modified_gmt":"2023-04-05T06:06:07","slug":"using-microsoft-edge-in-a-native-windows-desktop-app-part-4","status":"publish","type":"post","link":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/","title":{"rendered":"Using Microsoft Edge in a native Windows desktop app \u2013 part 4"},"content":{"rendered":"\n<p class=\"has-background wp-block-paragraph\" style=\"background-color:#ffead8\">This article in requiring Microsoft Edge WebView2 Runtime 88.0.705.50 or newer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the previous articles, we learned how to perform navigation in a Windows desktop application and how navigation events work. However, until recently, it was not possible to perform POST or GET request using custom headers or content. This feature was added in version 705.50. In this fourth article of the series, we will look in detail at how to perform POST requests with custom headers and content.<\/p>\n\n\n\n<div class=\"wp-block-group has-background\" style=\"background-color:#ffead8\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Articles in this series:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/mariusbancila.ro\/blog\/2020\/01\/28\/using-microsoft-edge-in-a-native-windows-desktop-app-part-1\/\" target=\"_blank\" rel=\"noopener noreferrer\">Part 1: Introduction to Edge and WebView2<\/a><\/li><li><a href=\"https:\/\/mariusbancila.ro\/blog\/2020\/01\/29\/using-microsoft-edge-in-a-native-windows-desktop-app-part-2\/\" target=\"_blank\" rel=\"noopener noreferrer\">Part 2: Creating a WebView2 component<\/a><\/li><li><a href=\"https:\/\/mariusbancila.ro\/blog\/2020\/01\/30\/using-microsoft-edge-in-a-native-windows-desktop-app-part-3\/\" target=\"_blank\" rel=\"noopener noreferrer\">Part 3: Navigation and other events<\/a><\/li><li>Part 4: Performing navigation with custom data and headers<\/li><li><a href=\"https:\/\/mariusbancila.ro\/blog\/2023\/03\/21\/using-microsoft-edge-in-a-native-windows-desktop-app-part-5\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Part 5: Executing JavaScript code<\/a><\/li><li><a href=\"https:\/\/mariusbancila.ro\/blog\/2023\/04\/05\/using-microsoft-edge-in-a-native-windows-desktop-app-part-6\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Part 6: Printing a web page<\/a><\/li><\/ul>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Overview<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are times when you must perform navigation to a page using a GET or POST request that requires custom headers or content (for a POST). This is not possible with the <code>ICoreWebView2::Navigate()<\/code> but it is available with <code>ICoreWebView2_2::NavigateWithWebResourceRequest()<\/code>. This method takes a pointer to an object implementing the <a href=\"https:\/\/docs.microsoft.com\/en-us\/microsoft-edge\/webview2\/reference\/win32\/icorewebview2webresourcerequest?view=webview2-1.0.664.37&amp;viewFallbackFrom=webview2-1.0.705.50\" target=\"_blank\" rel=\"noopener noreferrer\"><code>ICoreWebView2WebResourceRequest<\/code><\/a> interface. This interface defines an HTTP request, providing properties for the URI, method, headers, and content.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The argument passed to this function must be created with the <a href=\"https:\/\/docs.microsoft.com\/en-us\/microsoft-edge\/webview2\/reference\/win32\/icorewebview2environment2?view=webview2-1.0.721-prerelease#createwebresourcerequest\" target=\"_blank\" rel=\"noopener noreferrer\"><code>ICoreWebView2Environment2::CreateWebResourceRequest()<\/code><\/a> method. This method takes four input parameters for URI, method, content (i.e. post data), and headers, and an output parameter representing a pointer to the object that implements <code>ICoreWebView2WebResourceRequest<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The headers specified when calling this function override the headers added by WebView2 runtime except for <code>Cookie<\/code> headers. The HTTP method can only be <code>GET<\/code> or <code>POST<\/code>. The content you specify is sent only if the method is <code>POST<\/code> and the scheme is HTTP or HTTPS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Extending the CWebBrowser class<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this section, we will extent the <code>CWebBrowser<\/code> class seen in the previous articles, to support navigation with a POST request. For this purpose, we will first add a new method called <code>NavigatePost()<\/code>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CWebBrowser : public CWnd\n{\npublic:\n   void NavigatePost(CString const&amp; url, CString const&amp; content, CString const&amp; headers, CallbackFunc onComplete = nullptr);\n};<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the previous section, I have mentioned two new interfaces added to the SDK to support this new feature: <code>ICoreWebView2Environment2<\/code> and <code>ICoreWebView2_2<\/code>. We need to add pointers to these interfaces in order to call the required methods.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct CWebBrowserImpl\n{\n   wil::com_ptr&lt;ICoreWebView2Environment>    m_webViewEnvironment;\n   wil::com_ptr&lt;ICoreWebView2Environment2>   m_webViewEnvironment2;\n   wil::com_ptr&lt;ICoreWebView2>               m_webView;\n   wil::com_ptr&lt;ICoreWebView2_2>             m_webView2;\n   wil::com_ptr&lt;ICoreWebView2Controller>     m_webController;\n   wil::com_ptr&lt;ICoreWebView2Settings>       m_webSettings;\n};<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We need to make small changes to <code>OnCreateEnvironmentCompleted()<\/code> and <code>OnCreateWebViewControllerCompleted()<\/code> in order to initialize these variables.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">HRESULT CWebBrowser::OnCreateEnvironmentCompleted(\n   HRESULT result, \n   ICoreWebView2Environment* environment)\n{\n   CHECK_FAILURE(result);\n\n   if (!environment)\n      return E_FAIL;\n\n   CHECK_FAILURE(environment->QueryInterface(IID_PPV_ARGS(&amp;m_pImpl->m_webViewEnvironment)));\n   CHECK_FAILURE(environment->QueryInterface(IID_PPV_ARGS(&amp;m_pImpl->m_webViewEnvironment2)));\n\n   if (!m_pImpl->m_webViewEnvironment)\n      return E_FAIL;\n\n   CHECK_FAILURE(m_pImpl->m_webViewEnvironment->CreateCoreWebView2Controller(\n      m_hWnd,\n      Callback&lt;ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(\n         this,\n         &amp;CWebBrowser::OnCreateWebViewControllerCompleted).Get()));\n\n   return S_OK;\n}\n\nHRESULT CWebBrowser::OnCreateWebViewControllerCompleted(\n   HRESULT result,\n   ICoreWebView2Controller* controller)\n{\n   if (result == S_OK)\n   {\n      if (controller != nullptr)\n      {\n         m_pImpl->m_webController = controller;\n         CHECK_FAILURE(controller->get_CoreWebView2(&amp;m_pImpl->m_webView));\n\n         if (!m_pImpl->m_webView)\n            return E_FAIL;\n\n         CHECK_FAILURE(m_pImpl->m_webView->QueryInterface(IID_PPV_ARGS(&amp;m_pImpl->m_webView2)));\n\n         CHECK_FAILURE(m_pImpl->m_webView->get_Settings(&amp;m_pImpl->m_webSettings));\n\n         \/\/ We have a few of our own event handlers to register here as well\n         RegisterEventHandlers();\n\n         \/\/ Set the initial size of the WebView\n         ResizeEverything();\n      }\n\n      auto callback = m_callbacks[CallbackType::CreationCompleted];\n      if (callback != nullptr)\n         RunAsync(callback);\n   }\n   else\n   {\n      CString text;\n      GetAppObject()->GetLangText(TEXT_MSG, ERR_CANNOT_CREATE_WEBVIEW_ENV, 0, text);\n      ShowFailure(result, text);\n   }\n\n   return S_OK;\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">These variables should be set to <code>nullptr<\/code> when closing the web view.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void CWebBrowser::CloseWebView()\n{\n   if (m_pImpl->m_webView)\n   {\n      m_pImpl->m_webView->remove_NavigationCompleted(m_navigationCompletedToken);\n      m_pImpl->m_webView->remove_NavigationStarting(m_navigationStartingToken);\n      m_pImpl->m_webView->remove_DocumentTitleChanged(m_documentTitleChangedToken);\n\n      m_pImpl->m_webController->Close();\n\n      m_pImpl->m_webController = nullptr;\n      m_pImpl->m_webView = nullptr;\n      m_pImpl->m_webView2 = nullptr;\n      m_pImpl->m_webSettings = nullptr;\n   }\n\n   m_pImpl->m_webViewEnvironment = nullptr;\n   m_pImpl->m_webViewEnvironment2 = nullptr;\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The implementation of the <code>NavigatePost()<\/code> is fairly straight forward (based on the information from the Overview section):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ The raw request header string delimited by CRLF(optional in last header).\nvoid CWebBrowser::NavigatePost(CString const&amp; url, CString const&amp; content, CString const&amp; headers, std::function&lt;void()> onComplete)\n{\n   if (!m_pImpl->m_webView) return;\n\n   CString normalizedUrl{ NormalizeUrl(url) };\n\n   m_callbacks[CallbackType::NavigationCompleted] = onComplete;\n      \n   wil::com_ptr&lt;ICoreWebView2WebResourceRequest> webResourceRequest;\n   wil::com_ptr&lt;IStream> postDataStream = SHCreateMemStream(\n      reinterpret_cast&lt;const BYTE*>(static_cast&lt;LPCTSTR>(content)),\n      content.GetLength() + 1);\n\n   CHECK_FAILURE(m_pImpl->m_webViewEnvironment2->CreateWebResourceRequest(\n      CT2W(normalizedUrl),\n      L\"POST\",\n      postDataStream.get(),\n      CT2W(headers),\n      &amp;webResourceRequest));\n\n   CHECK_FAILURE(m_pImpl->m_webView2->NavigateWithWebResourceRequest(webResourceRequest.get()));\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Putting it to test<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To test this implementation, I have created a simple endpoint for a POST request using the <a title=\"Post Test Server V2 service\" href=\"https:\/\/ptsv2.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Post Test Server V2 service<\/a>. The endpoint description is available at <a title=\"https:\/\/ptsv2.com\/t\/jep76-1611756376\" href=\"https:\/\/ptsv2.com\/t\/jep76-1611756376\">https:\/\/ptsv2.com\/t\/jep76-1611756376<\/a>. What we&#8217;re doing here, is making a POST request using basic authorization, and therefore requiring the <code>Authorization<\/code> header. There is no content that is passed, and the response has the following body:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;h1>Thank you for trying this demo.&lt;\/h1>\n&lt;p>I hope you have a lovely day!&lt;\/p><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We can navigate to this URL with the following code (notice that the base64 encoding of the username:password text is hardcoded for simplicity):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void CMainFrame::OnBnClickedButtonTestPost()\n{\n   auto view = dynamic_cast&lt;CMfcEdgeDemoView*>(GetActiveView());\n   if (view != nullptr)\n   {\n      CString content;\n\n      \/\/ see https:\/\/ptsv2.com\/t\/jep76-1611756376\n      CString headers = L\"Authorization:Basic ZGVtbzpkZW1v\\r\\nUser-Agent:WebView2 Demo\";\n\n      view->NavigatePost(L\"https:\/\/ptsv2.com\/t\/jep76-1611756376\/post\", content, headers);\n   }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And this is the result of making this call:<br><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4168\" src=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgepost.png\" alt=\"\" width=\"620\" height=\"225\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgepost.png 620w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgepost-300x109.png 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, if we check the request dump at ptsv2.com, we can look at the headers. We can see the <code>Authorization<\/code> and the <code>User-Agent<\/code> headers had the content we provided in the previous snippet.<br><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4169\" src=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgeheaders.png\" alt=\"\" width=\"882\" height=\"555\" srcset=\"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgeheaders.png 882w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgeheaders-300x189.png 300w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgeheaders-768x483.png 768w, https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgeheaders-700x440.png 700w\" sizes=\"auto, (max-width: 882px) 100vw, 882px\" \/><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Try the app<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can download, build, and try the sample app for this series from here: <div class=\"wp-block-button\">\n<a  data-e-Disable-Page-Transition=\"true\" class=\"dlm-download-link dlm-download-default wp-block-button__link wp-element-button\" title=\"Version 6\" href=\"https:\/\/mariusbancila.ro\/blog\/download\/3689\/?tmstv=1792606239\" rel=\"nofollow\" id=\"download-link-3689\" data-redirect=\"false\" >\n\tMfcEdgeDemo.zip\t(<span class=\"dlm-download-count-value\">40671 downloads<\/span>\n\t)\n<\/a>\n<\/div>\n.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous articles, we learned how to perform navigation in a Windows desktop application and how navigation events work. However, until recently, it was not possible to perform POST or GET request using custom headers or content. This feature was added in version 705.50. In this fourth article of the series, we will look in detail at how to perform POST requests with custom headers and content.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","advgb_blocks_editor_width":"","advgb_blocks_columns_visual_guide":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[7,608,12,288],"tags":[263,451,616,617,453,55,459],"class_list":["post-4162","post","type-post","status-publish","format-standard","hentry","category-c","category-edge","category-mfc","category-win32","tag-browser","tag-c","tag-edge","tag-html","tag-mfc","tag-visualstudio","tag-windows"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Marius Bancila\"\/>\n\t<meta name=\"keywords\" content=\"c++,edge,browser,windows,mfc,html,visualstudio\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Marius Bancila&#039;s Blog | About code. Mostly on C++\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Using Microsoft Edge in a native Windows desktop app \u2013part 4\" \/>\n\t\t<meta property=\"og:description\" content=\"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2021-01-27T21:03:50+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2023-04-05T06:06:07+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Using Microsoft Edge in a native Windows desktop app \u2013part 4\" \/>\n\t\t<meta name=\"twitter:description\" content=\"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#article\",\"name\":\"Using Microsoft Edge in a native Windows desktop app \\u2013part 4\",\"headline\":\"Using Microsoft Edge in a native Windows desktop app \\u2013 part 4\",\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/edgepost.png\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#articleImage\",\"width\":620,\"height\":225},\"datePublished\":\"2021-01-27T23:03:50+02:00\",\"dateModified\":\"2023-04-05T08:06:07+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":5,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#webpage\"},\"articleSection\":\"C++, Edge, MFC, Win32, browser, C++, Edge, HTML, MFC, VisualStudio, Windows\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"position\":2,\"name\":\"IT\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"position\":3,\"name\":\"Software\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/#listItem\",\"name\":\"IT\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"position\":4,\"name\":\"C++\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/mfc\\\/#listItem\",\"name\":\"MFC\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/#listItem\",\"name\":\"Software\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/mfc\\\/#listItem\",\"position\":5,\"name\":\"MFC\",\"item\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/mfc\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#listItem\",\"name\":\"Using Microsoft Edge in a native Windows desktop app \\u2013 part 4\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/#listItem\",\"name\":\"C++\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#listItem\",\"position\":6,\"name\":\"Using Microsoft Edge in a native Windows desktop app \\u2013 part 4\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/category\\\/it\\\/software\\\/c\\\/mfc\\\/#listItem\",\"name\":\"MFC\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/\",\"name\":\"Marius Bancila\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Marius Bancila\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#webpage\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/\",\"name\":\"Using Microsoft Edge in a native Windows desktop app \\u2013part 4\",\"description\":\"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/2021\\\/01\\\/27\\\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/author\\\/admin\\\/#author\"},\"datePublished\":\"2021-01-27T23:03:50+02:00\",\"dateModified\":\"2023-04-05T08:06:07+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/\",\"name\":\"Marius Bancila's Blog\",\"description\":\"About code. Mostly on C++\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/mariusbancila.ro\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Using Microsoft Edge in a native Windows desktop app \u2013part 4","description":"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component.","canonical_url":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/","robots":"max-image-preview:large","keywords":"c++,edge,browser,windows,mfc,html,visualstudio","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#article","name":"Using Microsoft Edge in a native Windows desktop app \u2013part 4","headline":"Using Microsoft Edge in a native Windows desktop app \u2013 part 4","author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/mariusbancila.ro\/blog\/wp-content\/uploads\/2021\/01\/edgepost.png","@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#articleImage","width":620,"height":225},"datePublished":"2021-01-27T23:03:50+02:00","dateModified":"2023-04-05T08:06:07+02:00","inLanguage":"en-US","commentCount":5,"mainEntityOfPage":{"@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#webpage"},"isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#webpage"},"articleSection":"C++, Edge, MFC, Win32, browser, C++, Edge, HTML, MFC, VisualStudio, Windows"},{"@type":"BreadcrumbList","@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/mariusbancila.ro\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","position":2,"name":"IT","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","position":3,"name":"Software","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/#listItem","name":"IT"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","position":4,"name":"C++","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/#listItem","name":"MFC"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/#listItem","name":"Software"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/#listItem","position":5,"name":"MFC","item":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/","nextItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#listItem","name":"Using Microsoft Edge in a native Windows desktop app \u2013 part 4"},"previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/#listItem","name":"C++"}},{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#listItem","position":6,"name":"Using Microsoft Edge in a native Windows desktop app \u2013 part 4","previousItem":{"@type":"ListItem","@id":"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/#listItem","name":"MFC"}}]},{"@type":"Organization","@id":"https:\/\/mariusbancila.ro\/blog\/#organization","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","url":"https:\/\/mariusbancila.ro\/blog\/"},{"@type":"Person","@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author","url":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/","name":"Marius Bancila","image":{"@type":"ImageObject","@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a84dd2831d955c38355ddea55df4df260809b88f36408bc14fd4eab8f7f131c9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Marius Bancila"}},{"@type":"WebPage","@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#webpage","url":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/","name":"Using Microsoft Edge in a native Windows desktop app \u2013part 4","description":"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/mariusbancila.ro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/#breadcrumblist"},"author":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"creator":{"@id":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/#author"},"datePublished":"2021-01-27T23:03:50+02:00","dateModified":"2023-04-05T08:06:07+02:00"},{"@type":"WebSite","@id":"https:\/\/mariusbancila.ro\/blog\/#website","url":"https:\/\/mariusbancila.ro\/blog\/","name":"Marius Bancila's Blog","description":"About code. Mostly on C++","inLanguage":"en-US","publisher":{"@id":"https:\/\/mariusbancila.ro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Marius Bancila's Blog | About code. Mostly on C++","og:type":"article","og:title":"Using Microsoft Edge in a native Windows desktop app \u2013part 4","og:description":"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component.","og:url":"https:\/\/mariusbancila.ro\/blog\/2021\/01\/27\/using-microsoft-edge-in-a-native-windows-desktop-app-part-4\/","article:published_time":"2021-01-27T21:03:50+00:00","article:modified_time":"2023-04-05T06:06:07+00:00","twitter:card":"summary","twitter:title":"Using Microsoft Edge in a native Windows desktop app \u2013part 4","twitter:description":"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component."},"aioseo_meta_data":{"post_id":"4162","title":"Using Microsoft Edge in a native Windows desktop app \u2013part 4","description":"In this article you will learn how to perform navigation with a GET or POST method using custom headers and content using the Edge WebView2 component.","keywords":[{"label":"C++","value":"C++"},{"label":"Edge","value":"Edge"},{"label":"browser","value":"browser"},{"label":"Windows","value":"Windows"},{"label":"MFC","value":"MFC"},{"label":"HTML","value":"HTML"},{"label":"VisualStudio","value":"VisualStudio"}],"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"aioseo-article-636965220eb1a","slug":"article","graphName":"Article","label":"Article","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-18 21:02:54","updated":"2025-12-12 07:55:32","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"author_meta":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"featured_img":null,"jetpack_publicize_connections":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Marius Bancila","author_link":"https:\/\/mariusbancila.ro\/blog\/author\/admin\/"},"uagb_comment_info":5,"uagb_excerpt":"In the previous articles, we learned how to perform navigation in a Windows desktop application and how navigation events work. However, until recently, it was not possible to perform POST or GET request using custom headers or content. This feature was added in version 705.50. In this fourth article of the series, we will look&hellip;","coauthors":[],"tax_additional":{"categories":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/web\/edge\/\" class=\"advgb-post-tax-term\">Edge<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/c\/mfc\/\" class=\"advgb-post-tax-term\">MFC<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/win32\/\" class=\"advgb-post-tax-term\">Win32<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">Edge<\/span>","<span class=\"advgb-post-tax-term\">MFC<\/span>","<span class=\"advgb-post-tax-term\">Win32<\/span>"]},"tags":{"linked":["<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/win32\/\" class=\"advgb-post-tax-term\">browser<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/win32\/\" class=\"advgb-post-tax-term\">C++<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/win32\/\" class=\"advgb-post-tax-term\">Edge<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/win32\/\" class=\"advgb-post-tax-term\">HTML<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/win32\/\" class=\"advgb-post-tax-term\">MFC<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/win32\/\" class=\"advgb-post-tax-term\">VisualStudio<\/a>","<a href=\"https:\/\/mariusbancila.ro\/blog\/category\/it\/software\/windows-programming\/win32\/\" class=\"advgb-post-tax-term\">Windows<\/a>"],"unlinked":["<span class=\"advgb-post-tax-term\">browser<\/span>","<span class=\"advgb-post-tax-term\">C++<\/span>","<span class=\"advgb-post-tax-term\">Edge<\/span>","<span class=\"advgb-post-tax-term\">HTML<\/span>","<span class=\"advgb-post-tax-term\">MFC<\/span>","<span class=\"advgb-post-tax-term\">VisualStudio<\/span>","<span class=\"advgb-post-tax-term\">Windows<\/span>"]}},"comment_count":"5","relative_dates":{"created":"Posted 6 years ago","modified":"Updated 4 years ago"},"absolute_dates":{"created":"Posted on January 27, 2021","modified":"Updated on April 5, 2023"},"absolute_dates_time":{"created":"Posted on January 27, 2021 11:03 pm","modified":"Updated on April 5, 2023 8:06 am"},"featured_img_caption":"","series_order":"","jetpack_shortlink":"https:\/\/wp.me\/pYNdv-158","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/4162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/comments?post=4162"}],"version-history":[{"count":11,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/4162\/revisions"}],"predecessor-version":[{"id":4647,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/posts\/4162\/revisions\/4647"}],"wp:attachment":[{"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/media?parent=4162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/categories?post=4162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mariusbancila.ro\/blog\/wp-json\/wp\/v2\/tags?post=4162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}