Custom route does not work in ASP.net MVC 3

Posted by user603007 on Stack Overflow See other posts from Stack Overflow or by user603007
Published on 2012-06-01T04:21:53Z Indexed on 2012/06/01 4:40 UTC
Read the original article Hit count: 123

Filed under:
|
|

I am trying to implement my custom route in ASP.net MVC 3 but I get this error:

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);
    }
}

© Stack Overflow or respective owner

Related posts about asp.net-mvc-3

Related posts about c#-4.0