本文介绍了如何实现ResourceInterceptor Awesomium 1.7.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我已经看到了这个问题,在此线程
so, i've seen this question on this thread
基本上,我想知道我可以实现资源拦截,因为我无法找到它..我还使用C#和我通过对象浏览器搜索,并没有发现该类...
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...
这是我的code ..或多或少是相同的线程以上
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;
}
}
这不工作,任何建议?
推荐答案
下面是一个工作示例(使用.NET4 / 86):
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");
}
}
这篇关于如何实现ResourceInterceptor Awesomium 1.7.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!