i got Xilium.CefGlue working in my winforms application, this is my code:
- Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Xilium.CefGlue;
using Xilium.CefGlue.WindowsForms;
namespace CefGlueBrowser
{
public partial class Form1 : Form
{
private readonly string _mainTitle;
private CefWebBrowser _browser;
public Form1()
{
InitializeComponent();
_mainTitle = Text;
OpenAndBrowse("http://www.google.com");
}
private void OpenAndBrowse(string startUrl)
{
_browser = new CefWebBrowser();
_browser.StartUrl = startUrl;
_browser.Dock = DockStyle.Top;
_browser.Location = new Point(0, 0);
_browser.Size = new Size(1024, 768);
Controls.Add(_browser);
}
private void button1_Click(object sender, EventArgs e)
{
_browser.Browser.StopLoad();
_browser.Browser.GetMainFrame().LoadUrl("http://www.magpcss.org");
}
}
}
So basicly, i open a new form, add a browser and go to the page. Everything works like it should, but now i'm trying to redirect the requests from the browser to local files. After doing some research, i found out i need to implement the CefRequestHandler. But i have totally no idea on how to do this.
I've also tried with CefSharp and there i need to implement the iRequestHandler to get into the OnBeforeResourceLoad method and do the redirect there, which works, but CefGlue is alot better in my eyes so i really want to get this working.
Any help will be greatly appreciated.
Thanks in advance.