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

查看:90
本文介绍了南希(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>();

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

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