I am writing a game in XNA which is using Awesomium webviews as the UI. The webviews are rendered to Texture2D using this class.
It works great using local html files, but I also need to use some XML and Awesomium does not seem to allow for this (setting FileAccessFromFileURL and WebSecurity to false does nothing). My solution was to host my HTML/XML UI on a local web server, used this class for the server.
The web server is running fine and accessible from my browser but I get blank windows when I set my webview sources to http://localhost:8023/myindex.html. I do not get this output when I access localhost using the Awesomium WPF control, nor do I get it when I host the html remotely. This makes me think the issue is caused by how my class is handling URI's.
public struct AwesomiumMenu
{
public WebView webView;
public Microsoft.Xna.Framework.Rectangle Rectangle;
public AwesomiumMenu(string Source, Microsoft.Xna.Framework.Rectangle rectangle)
{
// WebPreferences to disable same-origin policy so we can load local XML + remove scrollbars
const string SCROLLBAR_CSS = "::-webkit-scrollbar { visibility: hidden; }";
WebSession session = WebCore.CreateWebSession(new WebPreferences()
{
CustomCSS = SCROLLBAR_CSS,
UniversalAccessFromFileURL = true,
FileAccessFromFileURL = true,
WebSecurity = false
});
//// CSS styling
//const string SCROLLBAR_CSS = "::-webkit-scrollbar { visibility: hidden; }";
//WebCore.Initialize(new WebConfig()
//{
// CustomCSS = SCROLLBAR_CSS
//});
webView = WebCore.CreateWebView(rectangle.Width, rectangle.Height, session);
webView.Source = Source.ToUri();
Console.WriteLine(webView.Source);
webView.IsTransparent = true;
while (webView.IsLoading)
WebCore.Update();
I use mongoose as my local server - very easy to use. I did simplest test application I could, and it works for me. Here is the entire code: