开发者

return a list of string as JSONResult

开发者 https://www.devze.com 2023-01-07 12:18 出处:网络
how would I return a list of string in a json result in C# asp.net MVC? I have this controller public JsonResult AutoCompletePart(string id)

how would I return a list of string in a json result in C# asp.net MVC?

I have this controller

  public JsonResult AutoCompletePart(string id)
    {
        AutoCompleteService srv = new AutoCompleteServ开发者_StackOverflow社区ice();
        string[] parts = srv.AutoCompleteItemMaster(id);

        //how do i return parts as JSON?

    }

Thanks


Like this:

return Json(parts, JsonRequestBehavior.AllowGet);

This will return a simple Javascript string array.
If you want to return specific format, please provide more detail.

0

精彩评论

暂无评论...
验证码 换一张
取 消