Home Json Helper Class in Razor Pages Project
Reply: 0

Json Helper Class in Razor Pages Project

user5484 Published in September 20, 2018, 12:45 pm

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

        if (!string.IsNullOrEmpty(text))
            products = products.Where(p => p.ProductName.Contains(text));

        return Json(products, JsonRequestBehavior.AllowGet);
share|improve this question

1 Answer 1

active oldest votes
up vote 0 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.400024 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO