Search code examples
c#.netwpfdotnetbrowser

C# and DotNetBrowser Ajax request do not work


I use a DotNetBrowser in my WPF application and I have a problem js

$(document).ready(function(){
  $.getJSON("data.json").success(function() {
      alert("succes");
  }).error(function(e) { 
      alert("error");
  });
});

error

Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

how fix??


Solution

  • You need to specify the --disable-web-security Chromium switch before creating any Browser or BrowserView instances:

    BrowserPreferences.SetChromiumSwitches("--disable-web-security");
    

    The following article provides more details about switches: https://dotnetbrowser.support.teamdev.com/support/solutions/articles/9000110017-chromium-switches