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


Please Help Members By Posting Answers For Below Questions

Explain the request flow in asp.net mvc framework?

1101


Possible ways to prevent xss attacks on mvc application?

1091


How to use multiple submit buttons in asp.net mvc?

1317