Awesomnium Post参数

Ton*_*y B 1 c# parameters post awesomium

目前我在C#环境中使用Awsomnium 1.7.我只是使用Core并尝试定义自定义帖子参数.现在,我搜索了很多,我甚至发布在awsomnium论坛,但没有答案.我理解这个概念,但最近的变化只是放弃了建议的机制和例子.

我找到了:http: //support.awesomium.com/kb/general-use/how-do-i-send-form-values-post-data

这样做的问题是,WebView类不再包含"OnResourceRequest"事件.到目前为止,我已经实现了IResourceInterceptor并且具有"OnRequest"-Function覆盖的公共ResourceResponse OnRequest(ResourceRequest请求)是签名,但我没有机会到达那里以添加请求头.这里有人有什么想法?我试着查看文档,但我没有找到任何关于.....

Hot*_*otN 5

您需要将IResourceInterceptor附加到WebCore,而不是WebView.这是一个有效的例子:

资源拦截器:

public class CustomResourceInterceptor : ResourceInterceptor
{
    protected override ResourceResponse OnRequest(ResourceRequest request)
    {
        request.Method = "POST";
        var bytes = "Appending some text to the request";
        request.AppendUploadBytes(bytes, (uint) bytes.Length);
        request.AppendExtraHeader("custom-header", "this is a custom header");

        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

主要应用:

public MainWindow()
{
    WebCore.Started += WebCoreOnStarted;
    InitializeComponent();
}

private void WebCoreOnStarted(object sender, CoreStartEventArgs coreStartEventArgs)
{
    var interceptor = new CustomResourceInterceptor();

    WebCore.ResourceInterceptor = interceptor;
    //webView is a WebControl on my UI, but you should be able to create your own WebView off WebCore
    webView.Source = new Uri("http://www.google.com");
}
Run Code Online (Sandbox Code Playgroud)