Nancy (C#):如何获取我的帖子数据? [英] Nancy (C#): How do I get my post data?

查看:25
本文介绍了Nancy (C#):如何获取我的帖子数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Corona SDK 将数据发布到我的 C# 服务器:

I'm using Corona SDK to post data to my C# server:

headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Accept-Language"] = "en-US"

local body = "color=red&size=small"

local params = {}
params.headers = headers
params.body = body

network.request( host .. "/UpdateHand", "POST", nwListener, params )

我在服务器上收到一条消息:

I receive a message on the server:

  Post["/UpdateHand"] = x =>
        {
            Console.WriteLine("Received ...");
            return "Ok";
        };

但是当我检查数据时(当我在上面放置断点时)我没有看到我的数据在哪里(即 params.body 或 params.headers).如何提取此信息?

But when I check the data (when I put a breakpoint on it) I don't see where my data is locaded (i.e. the params.body or params.headers). How can I extract this information?

我应该根据 Corona 上的文档正确发布它:http://docs.coronalabs.com/daily/api/library/network/request.html

I should POST it correctly according to the documentation on Corona: http://docs.coronalabs.com/daily/api/library/network/request.html

推荐答案

帖子数据在

this.Request.Body

如果你有合适的类型,你可以使用模型绑定反序列化你的数据:

If you have suitable type you can deserialize your data to it using model binding:

var x = this.Bind<YourType>();

这篇关于Nancy (C#):如何获取我的帖子数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆