It is not calling the action method because of [HttpPost]
and clicking on anchor tag actually does a Get
. So try remove the [HttpPost]
attribute decoration from your AddToCart
action.
[HttpPost]//<--Remove this
public ActionResult AddToCart(int id)
{
_shoppingCart.Add(id, 1);
return RedirectToAction("Index");
}