通过http GET将JSON对象发送到服务器

use*_*912 3 json asp.net-mvc-3

我正在寻找通过GET将JSON对象发送到服务器.Chris 通过JSON将对象数组发布到ASP.Net MVC3的答案适用于http POST,但不适用于GET.我的情况也适用于POST但不适用于GET.我可以做些什么让GET工作这是我的情况:在Controller中我有以下方法public ActionResult Screenreport(Screentable screendata)

   {
       // do something here
       return View();
   }
Run Code Online (Sandbox Code Playgroud)

我有两个ModelView如下:

   public class Screenrecord
   {
      public string Firstname{ get; set; }
      public string Lastname{ get; set; }
   }
   public class Screentable
   {
      public List<Screenrecord> Screenlist { get; set; } 
   }
Run Code Online (Sandbox Code Playgroud)

在客户端,我生成JSON对象

var Screentable = { Screenlist: screendata };
Run Code Online (Sandbox Code Playgroud)

screendata是一个Screenrecord数组

所有这些工作当我使用POST,但当我使用GET时,我得到空值(screendata = null)控制器的方法.换句话说,当单击GO时,屏幕截图(Screentable screendata)例程中的screendata为null.

此外,如果我发送一个JSON对象它可以工作,但如果我发送像我描述的数组(列表),它不会.我想做的是可行的吗?

Jam*_*ler 10

不:-)那不是如何得到的.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

(见9.3 GET)

"GET方法意味着检索由Request-URI标识的任何信息(以实体的形式)"

Request-URI是这里的重要部分.GET请求中没有正文数据的概念.