0

Iam tried to display json array,but instead of json i got xml.How can i display json array

public HttpResponseMessage jsonvalues()
     {
         {
             var retList = new List<string>();

             RootObject ro = new RootObject();
             DataTable dtaltheat = GetAlltheatredet();
             foreach (DataRow drow in dtaltheat.Rows)
             {

                 string theatnme = drow["TheatreName"].ToString();
                 ro.name = theatnme;
                 JavaScriptSerializer js = new JavaScriptSerializer();
                 var jsonString = JsonConvert.SerializeObject(ro);
                 if (jsonString != null)
                 {
                     retList.Add(jsonString);
                 }



                 // JavaScriptSerializer ser = new JavaScriptSerializer();
             }
             // return retList;
             return Request.CreateResponse(HttpStatusCode.OK, retList);
         }
     }

iam using to display datatable contents and its woriking fine,but my only problem is that to unable to display json array...

hakkeem
  • 185
  • 1
  • 4
  • 13

1 Answers1

0

take a look at this one: Returning JSON from a JsonResult method in MVC controller

Believe this is where you are looking for:

If using ASP.NET MVC 2 or higher:

return Json(resultset, JsonRequestBehavior.AllowGet);

Community
  • 1
  • 1