ReloadRoutes with ServiceRoute throws "A route with the resolved virtual path has already been added" exception
We have build a RouteProvider that stores route data in a database. Occasionally (mostly during development), we want to reload the route table without having to restart the application. For that we call the ReloadRoutes method on the provider and that worked very well until we added a ServiceRoute to our RouteCollection.
Since then, when trying to add the serviceRoute the second time (after routes.Clear()), the ServiceRouteHandler throws an exception. It i开发者_JAVA技巧s like the clear method on the RouteCollection did not clear it all. Now how can I clear the serviceroute ?
private void LoadRoutes(RouteCollection routeTable)
{
routeTable.Clear();
routeTable.IgnoreRoute("{resource}.axd/{*pathInfo}");
//Add some Route (woks fine)
// Add the service route to the application (throw exception the second time)
routeTable.Add(new ServiceRoute("Services/RouteProvider/", new WindsorServiceHostFactory<DefaultServiceModel>(), typeof(IRouteProviderService)));
}
精彩评论