我想实现在ASP.net MVC 3我的自定义路线,但我得到这个错误:自定义路由没有在ASP.net MVC工作3
The resource cannot be found.
Global.asax的
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"mycontroller", // Route name
"{controller}/{name}", // URL with parameters
new { controller = "MyController", action = "Search" } // Parameter defaults
);
}
MyController.cs
public class MyController : Controller
{
public ActionResult Search(string name)
{
return Content(name);
}
}
@TGH是我没有看到更新以上 – user603007
见我的答案,只需要升级到myController的我,甚至更好的改变名称更重要。您只需将您的控制器称为_ _并将约定称为控制器:_ Controller_ –
Jupaol