gpt4 book ai didi

c# - 如何实现 ResourceInterceptor Awesomium 1.7.1

转载 作者:行者123 更新时间:2023-11-30 20:55:31 27 4
gpt4 key购买 nike

所以,我在这个线程上看到了这个问题

Awesomnium Post Parameters

基本上我想知道如何实现资源拦截器,因为我找不到它。我也在使用 C#,我在对象浏览器中搜索并没有找到类...

这是我的代码..或多或少与上面的线程相同

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;
}
}

这行不通,有什么建议吗?

最佳答案

这是一个工作示例(使用 .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");
}
}

关于c# - 如何实现 ResourceInterceptor Awesomium 1.7.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18248851/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com