使用asp.net的HTTP POST方法 [英] HTTP POST method using asp.net

查看:181
本文介绍了使用asp.net的HTTP POST方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HTTP post方法从客户端捕获数据...



所以使用HTTP POST时最好使用分割器发送数据字符串还是json?



和为什么?

I'm using HTTP post method to catch data from a client...

so when using HTTP POST is it better to send the data string using splitters or json?

and why?

推荐答案

在json你会传递像

In json you'd pass something like
{"id":12, "firstname":"pascal","lastname":"ganaye"}



鉴于分配器


Whereas with a splitter

12|Pascal|GANAYE





Json

* easy:你可以找一个库来编写和解析它

*标准:它是一个文档化的标准,所以理解json的人会很容易理解

*可扩展:通过设计json是可扩展的,你可以在以后轻松添加更多数据甚至复杂数据。



splitter

*甚至更容易:你可以使用string.split string.join

* compact: |版本较短

*危险:如果你的数据中有分隔符怎么办

*模糊:12 | Pascal | GANAYE的人类可读性低于json版本

*可扩展性较低:拆分器不允许传递数组或内部对象

* riskier:如果在开头插入一个额外的参数,因为参数不是名称,那么更多的不匹配风险。



总的来说,如果您发送的数量不是太大,我会坚持使用json。

只有当你发送兆字节和速度是至关重要的,然后我可能会考虑别的东西,但不是分裂器,而是二进制。



Json is
* easy : you can find a library to write and parse it
* standard : it is a documented standard, so people who understand json will understand easily
* extensible : by design json is extensible you can easily add more data and even complex data later.

A splitter is
* even easier : you can use string.split string.join
* compact: the | version is shorter
* dangerous : what if you have a delimiter in your data
* obscure : 12|Pascal|GANAYE is less human readable than the json version
* less extensible : the splitter won't allow you to pass arrays or inner objects
* riskier : if you insert an extra parameter at the beginning as the parameters are not name there is more mismatch risks.

Overall if the volume of what you send is not too big I would stick with json.
Only if you're sending megabytes and speed is paramount then I might consider something else but then not a splitter but something binary.


这篇关于使用asp.net的HTTP POST方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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