2013-03-10 44 views
0

嗨在我的MVC應用程序我試圖導航到詳細信息視圖MVC - Cant't導航到詳細信息視圖ASP.NET

這是我在控制器代碼

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> 

我已經創建詳細信息視圖 喜歡這個

enter image description here

但問題是,當我試圖導航到詳細信息視圖我收到此錯誤

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 

我很困惑,因爲頁面已經是t在這裏,我錯過了什麼?

回答

0

您可以嘗試將aspx重命名爲cshtml。 請參閱您的ProviderBinders和路由在全球ASAX

+0

我已經更新了問題 – Rakesh 2013-03-10 08:55:30

+0

粘結劑你用什麼? – Mediator 2013-03-10 16:19:48

+0

LINQ To Entities – Rakesh 2013-03-10 18:34:52