0

我想在 mvc asp .net Web 服务中编写 http 帖子,该服务从 android 应用程序中获取 BasicNameValuePair 返回一个 Json 数组。

你能帮助伙计们吗?

4

2 回答 2

0
[HttpPost]
[WebMethod(EnableSession = true)]
public string change()
{

     int i=Request["id"] != null;
     System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
     new System.Web.Script.Serialization.JavaScriptSerializer();
     string sJSON = oSerializer.Serialize(oList);
     return sJSON;
}
于 2013-08-15T09:17:50.843 回答
0

不完全确定您的要求,但听起来您想要一个接收键值对列表并返回 json 的端点。可以这样做:

[HttpPost]
public JsonResult MyMethod (IDictionary<string, object> inputParam) {
    var myArray = GetArrayFromSomewhere(inputParam); //possibly another webservice or database
    return Json(myArray, JsonRequestBehaviour.DenyGet);
} 
于 2013-08-15T09:32:42.833 回答