I created a simple project and I can't seem to access the Json Helper class that I see through a bunch of sample projects. For example, I'm trying to use the Telerik dropdown sample and in the code below, I get the error:
The name Json does not exist in the current context.
(same thing goes for JsonRequestBehavior) What am I missing? I've done a search in nuget for
System.Web.Helpers, but I can't add the reference because the project is targeted for ASP.NET Core 2.0 while the assembly was restored using .NET 4.6.1. What is my alternative?
public JsonResult RemoteDataSource_GetProducts(string text)
var northwind = new SampleEntities();
var products = northwind.Products.Select(product => new ProductViewModel
ProductID = product.ProductID,
ProductName = product.ProductName,
UnitPrice = product.UnitPrice ?? 0,
UnitsInStock = product.UnitsInStock ?? 0,
UnitsOnOrder = product.UnitsOnOrder ?? 0,
Discontinued = product.Discontinued
products = products.Where(p => p.ProductName.Contains(text));
return Json(products, JsonRequestBehavior.AllowGet);