Reputation: 7039
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 AutoCompleteService();
string[] parts = srv.AutoCompleteItemMaster(id);
//how do i return parts as JSON?
}
Thanks
Upvotes: 7
Views: 10156
Reputation: 888167
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.
Upvotes: 14