There's no response because your code does not submit the Id. If you were using debug tools like Dev Tools you should see errors. Also if you set a break point in VS you'll notice the action is not hit.
IMHO, your filter design is a little confusing too. Anyway, below is a basic example that builds my previous posts.
public class HomeController : Controller
{
private readonly TestDbEntities context;
public HomeController()
{
context = new TestDbEntities();
}
[HttpGet]
public ActionResult Index()
{
var results = context.T_Projects;
return View(results);
}
[HttpPost]
public JsonResult Search(string Category)
{
//Projection query to populate the product view model
List<ProductViewModel> products = (from prod in context.T_Projects
where prod.T_ProjeCategory.KategoriAd == Category
select new ProductViewModel()
{
Baslik = prod.Baslik,
Icerik = prod.Icerik,
ProductId = prod.ID,
ResimYolu = prod.ResimYolu
}).ToList();
return Json(products);
}
public class ProductViewModel
{
public int ProductId { get; set; }
public string Baslik { get; set; }
public string Icerik { get; set; }
public string ResimYolu { get; set; }
}
Feel free to modify the example to fit your needs. Remember to use the debugging tools and make at least an attempt to troubleshoot.
All-Star
52261 Points
23317 Posts
Re: Asp.Net Core Category - Product
Sep 15, 2019 06:02 PM|mgebhard|LINK
There's no response because your code does not submit the Id. If you were using debug tools like Dev Tools you should see errors. Also if you set a break point in VS you'll notice the action is not hit.
IMHO, your filter design is a little confusing too. Anyway, below is a basic example that builds my previous posts.
View
Model
Feel free to modify the example to fit your needs. Remember to use the debugging tools and make at least an attempt to troubleshoot.