Cross Domain request between File and Http

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

Cross Domain request between File and Http

Postby Riain » Thu Jul 18, 2013 3:51 am

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
Riain
Newbie
 
Posts: 2
Joined: Thu Jul 18, 2013 3:48 am

Re: Cross Domain request between File and Http

Postby magreenblatt » Thu Jul 18, 2013 1:02 pm

magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Cross Domain request between File and Http

Postby Riain » Fri Jul 19, 2013 2:00 am

Fantastic, thank you!
Riain
Newbie
 
Posts: 2
Joined: Thu Jul 18, 2013 3:48 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 14 guests