2016-12-05 89 views
-1

我想在My MVC應用程序中實現路由。MVC的路由問題

routes.MapRoute("View", 
       "View/ViewCustomer/{id}", 
       new { controller = "Customer", action = "DisplayCustomer", 
id = UrlParameter.Optional }); 

上面的代碼不會重定向到CustomerDetail控制器。

我想用上面的url來調用它。 http://localhost/View/ViewCustomer/

+1

您的路由適用於名爲'CustomerController'的控制器,而不是'CustomerDetailController' –

回答

0

你可以這樣

routes.MapRoute("View", 
       "View/ViewCustomer/{id}", 
       new { controller = "CustomerDetail", action = "DisplayCustomer", 
id = UrlParameter.Optional }); 

它應該是控制器= 「爲CustomerDetail」 更改密碼。