float 的模型绑定失败

Model binding for float fails

我正在尝试将 window 的位置发送到服务器。但是 top 的模型绑定总是失败。我的操作方法如下:

public void winClosed(Window position)

和 window 模型:

public class Window
{
    public decimal Left { get; set; }
    public double Top { get; set; }
}

在此图片中,您可以看到示例值:

最后 JavaScript 代码:

var position = this.wrapper.offset();
$.post("@Url.Action("winClosed", "Home")", position);

第一行相对于Kendo Window。我已经在模型中尝试了 doublefloat 类型。

您的区域性 (fa-IR) 的小数分隔符是 /(正斜杠)字符。您需要将 . 字符替换为 / 字符。例如

var offset = this.wrapper.offset();
var l = offset.left.toString().replace('.', '/');
var t = offset.top.toString().replace('.', '/');
$.post("@Url.Action("winClosed", "Home")", {left: l, top: t });