How to return the JSON from action method in ASP.Net MVC?
Answer / 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 |
Is dapper faster than entity framework?
what is ssdl?
What is MVVM design pattern?
When using razor views, do you have to take any special steps to protect your asp.net mvc application from cross site scripting (xss) attacks?
How we can invoke child actions in ASP.Net MVC?
Possible ways to prevent xss attacks on mvc application?
What is meant by bootstrap in mvc5?
how do you mark a property as required? For example, for a project, the name is a required field.
Can I add asp.net mvc testcases in visual studio express?
What are the new features 3.5 framework against with the tool?
What are the ways to deploy an assembly?
WHICH IS MORE SECURED AMONG JAVA AND .NET?