Is there an example or method of passing objects from a web page to a backend program?
Closed this issue · 2 comments
From Vue's sample code, I see the following methods, but can only pass the type of string, or should we use JSON. stringify() or other methods?
.RegisterWebMessageReceivedHandler((object sender, string message) =>
{
var window = (PhotinoWindow)sender;
// The message argument is coming in from sendMessage.
// "window.external.sendMessage(message: string)"
string response = $"Received message: \"{message}\"";
// Send a message back the to JavaScript event handler.
// "window.external.receiveMessage(callback: Function)"
window.SendWebMessage(response);
})
If it is a JSON object you would have to stringify it on the Javascript side and parse it in C# to create a typed object. For binary formats like images, you'd have to base64 encode it in JS and decode it in C# to get the corresponding byte[]
. Other compatible formats might work as well, like hex conversion, as long as it is a string format you will be able to pass it back and forth.
Hey, sorry to reopen a closed issue but I was wondering how I could cleanly have the backend handle multiple type of requests?
I thought I could use a param in the JSON message I send that would be the requestName and then use a case switch statement to get to the right logic. It just seems like it's the wrong approach though.
I would like to make a local app but have the C# side handle the logic.
BTW the concept of that Framework is great and pretty easy to setup.