为什么我的 Nancy 调用 Bind<T>() 返回一个空对象?

Why is my Nancy call to Bind<T>() returning an empty object?

我无法让 Bind<T>() 方法处理 Nancy 中的 POST 请求。我有这个 class *:

public class MyPost
{
    public string title { get; set; }
    public string content { get; set; }
}

我有这个 NancyModule,它简单地反映了 POST 数据:

public class ConfigModule : NancyModule
{
    public ConfigModule() : base("/config")
    {
        Post["/update"] = parameters =>
        {
            var mypost = this.Bind<MyPost>();
            return Response.AsJson<MyPost>(mypost);
        };
    }
}

当我使用 Chrome 扩展邮递员发送此 POST 请求时:

POST /config/update HTTP/1.1
Host: localhost:9664
Cache-Control: no-cache

{ "title": "my title 33", "content": "my content" }

我收到这样的回复:

{
    "title": null,
    "content": null
}

当我调试 post 方法时,我发现 mypost 对象的所有属性都是空的。为什么是这样?当我调用 this.Request.Body.AsString() 时,我得到了我期望的 POST 数据。

* 我将 属性 名称设为小写,因为当我使用 Response.AsJson(arg) 将 MyPost 对象转换为 JSON 时,键是小写的。

通过

下面的 orange JSON (application/json)Content-Type 设置为 application/json