AttributeRouting icon indicating copy to clipboard operation
AttributeRouting copied to clipboard

Routes are not registering

Open sakopov opened this issue 11 years ago • 1 comments

Trying to get routes to work with MVC 4.0.

Global.asax calls AttributeRouting to set things up:

        RouteTable.Routes.MapAttributeRoutes(config =>
            {
                config.AddRoutesFromAssembly(Assembly.GetExecutingAssembly());
            });

Here is my controller action

    [Route("account/login", HttpVerbs.Get)]
    public ActionResult Index()
    {
        return View();
    }

When i run this Routes.axd shows 0 routes. The MapAttributeRoutes call is running but doesn't pick up any routes. The interesting thing is i can get routes to work in Web API project, but no dice with MVC.

EDIT:

Another weird thing is that i'm not able to pass any controller when mapping routes:

        routes.MapAttributeRoutes(config =>
            {
                config.AddRoutesFromController<HomeController>();
            });

Will throw an exception stating that HomeController violates the constraint of type parameter 'T' or in another words doesn't implement IController which is bogus. It's really starting to sound like there are some compatibility issues with MVC 4.

sakopov avatar Nov 25 '13 00:11 sakopov

Ever find a solution for this? I'm getting the same error.

johnGeorge4 avatar Apr 10 '24 19:04 johnGeorge4