相关文章推荐
睿智的柿子  ·  cef qt - Bigben ·  1 月前    · 
绅士的抽屉  ·  CEF Forum • ...·  2 周前    · 
无邪的煎饼  ·  Format Query Results ...·  2 年前    · 

Chromium Embedded Framework Forum

Forum for support and discussion of the Chromium Embedded Framework (CEF)
Visit the CEF Project Site to download CEF and report issues.

Cross Domain request between File and Http

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.
Moderator: fddima
Hi,

Firstly, fantastic project!!

I'm creating an offline app that loads a html file into the browser control. This is working fine:

cefWebBrowser1.Browser.GetMainFrame().LoadUrl("file:///" + Application.StartupPath.Replace('\\', '/') + "/HTML/index.html");

Index.html calls some javascript that makes an AJAX request to a service held on my localhost (will eventually be moved to live server):

$.ajax({
url: "http://localhost:49203/Service.svc/MyMethod",
data: "{ 'id': '" + id + "'}",
success: function(data, success, methodName) {
var oData = jQuery.parseJSON(data.d);
console.log(oData);

},
...
}

However, I get the following error when this request is made:

XMLHttpRequest cannot load http://localhost:49203/Service.svc/MyMethod . Origin file:// is not allowed by Access-Control-Allow-Origin.

How can I get my CefWebBrowser to allow this cross domain request between File and HTTP?

I have tried the following but its not making any difference.:

CefRuntime.AddCrossOriginWhitelistEntry("file://", "http", "localhost:49203", true);

Any help would be greatly appreciated.

Thanks and again great project.
Riain