我正在尝试在 ASP.net MVC 3 中实现我的自定义路由,但出现此错误:
The resource cannot be found.
全球.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
);
}
我的控制器.cs
public class MyController : Controller
{
public ActionResult Search(string name)
{
return Content(name);
}
}