添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
知识渊博的柠檬  ·  typescript - How to ...·  1 年前    · 
满身肌肉的扁豆  ·  Format 函数 (Visual ...·  2 年前    · 
乐观的西瓜  ·  GitHub Copilot ...·  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