如何从 Nancy 2.0 上的 POST 请求中获取数据?
How do I get data from a POST request on Nancy 2.0?
我需要使用 NancyFX 2.0 实现 POST 请求处理程序。与 GET 请求相反,我不明白如何处理 Nancy 2.0 上的 POST,因为 url 和参数变量中都没有任何数据。
我目前的代码如下:
我的 NancyModule Post 方法:
Post("/add/{firstname:string}", parameters => AddAction(parameters));
AddAction 方法:
dynamic AddAction(dynamic parameters)
{
//I would need to print the JSON or bind it into a Client object here
}
这是我的客户class:
public Client(int id, string firstName, string lastName, string address)
{
ID = id;
FirstName = firstName;
LastName = lastName;
Address = address;
}
您可以在处理程序中像这样对绑定进行建模:var c = this.Bind<Client>();
。
我需要使用 NancyFX 2.0 实现 POST 请求处理程序。与 GET 请求相反,我不明白如何处理 Nancy 2.0 上的 POST,因为 url 和参数变量中都没有任何数据。
我目前的代码如下:
我的 NancyModule Post 方法:
Post("/add/{firstname:string}", parameters => AddAction(parameters));
AddAction 方法:
dynamic AddAction(dynamic parameters)
{
//I would need to print the JSON or bind it into a Client object here
}
这是我的客户class:
public Client(int id, string firstName, string lastName, string address)
{
ID = id;
FirstName = firstName;
LastName = lastName;
Address = address;
}
您可以在处理程序中像这样对绑定进行建模:var c = this.Bind<Client>();
。