问题
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