Я изменил пример демонстрации, чтобы попытаться отправить объект json, а не строку. Веб-сайт видит в нем строку значений [объект], а не текст Json. Что мне нужно изменить.
namespace DemoScript {
// [Imported]
// [IgnoreNamespace]
public sealed class Person
{
public string FirstName;
public string LastName;
}
[GlobalMethods]
internal static class HelloPage {
static HelloPage() {
// Add script that runs on startup as the script is loaded into
// the page
Element helloButton = Document.GetElementById("helloButton");
Person p = new Person();
helloButton.AddEventListener("click", delegate(ElementEvent e) {
InputElement nameTextBox = Document.GetElementById("nameTextBox").As<InputElement>();
p.FirstName = nameTextBox.Value;
p.LastName = "Surname";
XmlHttpRequest xhr = new XmlHttpRequest();
// xhr.Open(HttpVerb.Get, "/HelloService.ashx?name=" + nameTextBox.Value.EncodeUriComponent());
xhr.Open(HttpVerb.Get, "/HelloService.ashx?name=" + p);
...
}
}
}
Если я передаю p.FisrtName, все работает как положено.