How to Implement ResourceInterceptor Awesomium 1.7.1

馋奶兔 提交于 2019-12-24 00:57:18

问题


so, i've seen this question on this thread

Awesomnium Post Parameters

basically i want to know how i can implement the Resource Interceptor, cause i can't find it.. i'm also using c# and i search through the object browser and didn't find the class...

this is my code.. more or less is the same as thread above

public class CustomInter : ResourceInterceptor
{
    protected override ResourceResponse OnRequest(ResourceRequest request)
    {
        request.Method = "POST";
        request.AppendUploadBytes("klik_login=1&outkey=323e82945803f3eb68798709237d2ac7&username=asd&password=asd123", 100);
        request.AppendExtraHeader("Content-Type", "application/x-www-form-urlencoded");
        return null;
    }
}

this doesnt work, any suggestion?


回答1:


Here is a working sample (using .NET4 / x86) :

public class customInter : IResourceInterceptor
{
    public ResourceResponse OnRequest(ResourceRequest request)
    {
        // Put your code here
        return null;
    }

    public bool OnFilterNavigation(NavigationRequest request)
    {
        return false;
    }
}

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void WebCoreOnStarted(object sender, 
                                  CoreStartEventArgs coreStartEventArgs)
    {
        var interc = new customInter();
        WebCore.ResourceInterceptor = interc;
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        var interc = new customInter();
        WebCore.ResourceInterceptor = interc;

        // Replace "webControl1" and Uri with your information
        this.webControl1.Source = new Uri("http://example-site.com");
    }
}


来源:https://stackoverflow.com/questions/18248851/how-to-implement-resourceinterceptor-awesomium-1-7-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!