I am trying to submit a form with JQuery to C#, using a Value Tuple as one of the properties of the target object.
However, it doesn't seem to work; which I am guessing has something to do with how Value Tuples are constructed, as you also get errors when passing in values in the same manner Obj.Prop=x&etc..
to objects without a default constructor.
Below is what I am doing. I am wondering if there is a way to do it in a similar manner. I know I could create an object matching the Tuple in it's place or break the properties up and manually alter the serialization string; but I was hoping to avoid those if possible.
$.ajax({
url: '.../MyMethod',
data: $('#MyForm').serialize(),
succss: function (result) {
blah();
},
error: function (e) {
blah();
}
});
The form serialization creates:
Id=4&Time.Hour=16&Time.Minute=30
MyMethod has a parameter of SubmissionObject submission
which looks like:
public class SubmissionObject
{
public long Id { get; set; }
public (short Hour, short Minute) Time { get; set; }
}
However, the object will populate as
Id: 4
Time: (0, 0)
instead of
Id: 4
Time: (16, 30)