how to return multiple variables with jsonresult asp.net mvc3

asp.net-mvc-3, json, razor

Solution

 public ActionResult YourAction()
 {
   var result=new { Result="Successed", ID="32"};
   return Json(result, JsonRequestBehavior.AllowGet);
 }

EDIT : As per the comment "How to get this data in client"

You can use `getJSON` from view to get this data like this

$(function(){
   $.getJSON('YourController/YourAction', function(data) {
      alert(data.Result);
      alert(data.ID);
   });
});

Make sure you have jQuery loaded in your view for this code to work.

Problem

How to return multiple variables on JsonResult method for example i want to return this two variables: ``` string result = "Successed"; string ID = "32" ``` I know how to return only one string: ``` return Json("Inserted"); ```

Original source