I am trying to abstract out the route registraion process out of global.asax into a bootstrapper. My class looks like:
public class RegisterRoutes : IBootstrapperTask
{
private readonly RouteCollection routes;
public RegisterRoutes(RouteCollection routes)
{
this.routes = routes;
}
public RegisterRoutes() : this(RouteTable.Routes)
{
}
public void Execute()
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
My global.asax looks like:
protected void Application_Start()
{
Bootstrapper.Run();
}
My simplified bootstrapper looks like:
public static class Bootstrapper
{
static Bootstrapper()
{
// wires up the container
}
public static void Run()
{
container.ResolveAll<IBootstrapperTask>().Each(t => t.Execute());
}
}
The container resolver fine but when I try to execute the tasks I get: InvalidOperationException - The type VirtualPathProvider cannot be constructed. You must configure the container to supply this value.
Any feedback would be appreciated.
Thanks