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

Route Constraints using Ninject #228

Open hernangm opened 11 years ago

hernangm commented 11 years ago

It would be great if an extensibility point could be added so route constraints can be instantiated through a dependency injector such as Ninject. In many cases, I need to query a dbcontext to verify if the route matches (I can think of many other services that might be useful to have injected in the route constraint) and it would be ideal if the implementation of the service could be decoupled from its interface.

mccalltd commented 11 years ago

Hmm, nifty concept. Have you tried using a custom IRouteConstraintFactory? You can wire it up via config:

routes.MapAttributeRoutes(config => {
    // ...
    config.RouteConstraintFactory = new CustomRouteConstraintFactory();
});