我需要一个登录的帖子请求。我正在 WPF 中使用 webview2 包并使用它。
我的代码是这样的:
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri("Sample_url"));
request.Content = new FormUrlEncodedContent(new[] {
new KeyValuePair<string, string>("email", email),
new KeyValuePair<string, string>("password", "123"),
});
// webview2 does not contain a defenition for 'NavigateWithHttpRequestMessage'
Browser.NavigateWithHttpRequestMessage();
Run Code Online (Sandbox Code Playgroud)
我想做的是先登录用户,然后向他展示视图。
使用WebView2 version 1.0.790-prelease(可能更早),您可以CoreWebView2WebResourceRequest使用webView.CoreWebView2.Environment.CreateWebResourceRequest(). 然后可以将其传递给NavigateWithWebResourceRequest.
因此,例如:
var request = webView.CoreWebView2.Environment.CreateWebResourceRequest(navigateData.Url,
"POST", postData, "Content-Type: application/x-www-form-urlencoded");
webView.CoreWebView2.NavigateWithWebResourceRequest(request);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9519 次 |
| 最近记录: |