C# How To return List<> As Json
The compiler is unhappy with your code because you are saying that your method (I'm guessing action method) is defined to return List<Chat>
and you are returning JsonResult
. If you are using ASP.NET MVC it should look like this:
public ActionResult GetNewChatPosts(){ var userID = U_rep.GetUserID(User.Identity.Name); var list = G_rep.GetNewestChat(0, userID); return Json(list);}