I'm new in asp.net mvc and want to return json with web api controller,for that purpose write this code:
public JsonResult Get()
{
var users = GetUsers();
return Json(users, JsonRequestBehavior.AllowGet);
}
private List<TestModel> GetUsers()
{
var usersList = new List<TestModel>
{
new TestModel
{
id = "1",
name = "behzad"
}
};
return usersList;
}
but int this line:
JsonRequestBehavior.AllowGet
get this error:
Severity Code Description Project File Line Suppression State Error CS1503 Argument 2: cannot convert from 'System.Web.Mvc.JsonRequestBehavior' to 'Newtonsoft.Json.JsonSerializerSettings' WebApplication1 D:\behzad\project\aspweb api\WebApplication1\WebApplication1\Controllers\HelloController.cs 17 Active