adspace
How to return the JSON from action method in ASP.Net MVC?
Answer Posted / Shamim Ahmad
To return JSON from an action method in ASP.NET MVC, you can use the `JsonResult` class. Here's a simple example:
```
public ActionResult GetData()
{
var data = new { Key1 = "Value1", Key2 = "Value2" };
return Json(data);
}
```
In this example, the method returns a JSON object containing 'Key1' and 'Key2' properties.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers