Hello People i have a list of Customers (with Name and Id) that i have hardcoded in my Customers Controller as: Click to view Customer Controller i am sending list to a view named Customer to display all the three customers with their names as links using following code :
@model IEnumerable<App.Models.Customer>
@{
ViewBag.Title = "Customer";
}
@foreach (var customer in Model)
{
<li>
@Html.ActionLink(customer.Name, "Details", "Customers", new { id = customer.Id }, null)
</li>
}
It displays list of customers but problem is when i click any customer name(Which is a link) it gives a HTTP 404 error as :Click to see Error details i have made a Details method in Costumers Controller as
[HttpPost]
public ActionResult Details(int id)
{
var customer = GetCustomers().SingleOrDefault(x => x.Id == id);
if (customer == null)
{
return HttpNotFound();
}
return View(customer);
}
that recieves id of the customer name being clicked and simply displays its name again but it doesnt works and gives 404 error i have debugged the code and what i have found that control never reached the details Method in Controller, is the issue in ActionLink or what ? Help is highly appreciated thank you
[HttpPost]attribute from theDetails()method