mccalltd / AttributeRouting

Define your routes using attributes on actions in ASP.NET MVC and Web API.
http://mccalltd.github.io/AttributeRouting/
MIT License
416 stars 89 forks source link

Routes are not registering #279

Open sakopov opened 10 years ago

sakopov commented 10 years ago

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.

johnGeorge4 commented 6 months ago

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