嗨在我的 MVC 应用程序中,我正在尝试导航到详细信息视图
这是我在控制器中的代码
public class CustomerController : Controller
{
//
// GET: /Customer/
public ActionResult Index()
{
NorthWindEntity db = new NorthWindEntity();
var Data = db.Customers;
return View(Data);
}
public ActionResult Details(string id)
{
NorthWindEntity db = new NorthWindEntity();
var Data = db.Customers.Where(e => e.CustomerID == id).Select(e => e).Single();
return View(Data);
}
}
这是全局 asax 中的代码
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Customer", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
这是导航主页中的代码
<td>
<%: Html.ActionLink("Edit", "Edit",new { id=item.CustomerID }) %> |
<%: Html.ActionLink("Details", "Details", new { id = item.CustomerID })%> |
<%: Html.ActionLink("Delete", "Delete", new { id=item.CustomerID })%>
</td>
我已经像这样创建了详细信息视图
但问题是当我尝试导航到详细信息视图时出现此错误
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies)
could have been removed, had its name changed, or is temporarily unavailable.
Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Customer/Details/1
我很困惑,因为页面已经存在,我错过了什么。?