I'm facing an issue with the data being returned from C# to JS. Here is my CefSharp configuration:
Cef.Initialize();
CefSharpSettings.WcfEnabled = true;
CefSharpSettings.LegacyJavascriptBindingEnabled = true;
browser = new ChromiumWebBrowser("")
{
Dock = DockStyle.Fill
};
this.Controls.Add(browser);
SM = new ScriptManager(browser);
browser.RegisterAsyncJsObject("external", SM); //"Support" for C# methods from JavaScript
I am attempting to call a C# method from JS:
...
var UserID_array = window.external.loadUsrIDs(usr_names); //usr_name -> array of user names
In C#, the method declaration looks like this:
class ScriptManager
{
...
public int[] loadUsrIDs(object usr_names = null) //by default if usr_names == null then return all user IDs
{
...//reading the database
return id_users.ToArray(); //from List<int> to int[]
}
}
Unfortunately, instead of receiving an Int array (int[]), I always get the value: [object Promise] - here's some test code:
var UserID_array = window.external.loadUsrIDs(usr_names);
alert(UserID_array); //alert - only for tests
//The alert function always returns the value: [object Promise]
How can I access the data returned by the C# method in JS?
Best regards,
Marcin