maui how to proxy for WebView (windows platforms)

zd yu 41 Reputation points MVP
2022-12-09T06:47:35.943+00:00
Microsoft.Maui.Handlers.WebViewHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>  
		{  
			#if WINDOWS  
			var webView = handler.PlatformView; // Get the native android webview.  
                    // how to set proxy  
			#endif  
  
		});  
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,143 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2022-12-09T08:53:36.157+00:00

    Hello,

    You may have encountered this issue when referencing this thread to set up the proxy How to use Proxy for current version of WebView2 (1.0.705.50), when in fact, the two WebView2s are not in the same namespace.

    On MAUI, it is in Microsoft.UI.Xaml.Controls namespace, and there is no such an api to set environment in this class.

    As the matter of fact, the ability to set a separate proxy for WebView2 on Windows is not officially supported, you can refer to Does webview2 has proxy feature programmatically #1311.

    On Windows, your WebView2 will use the proxy settings of your Internet Explorer or Edge browser directly.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.