使用 ServiceRoute 的 ReloadRoutes 会抛出“已添加具有已解析虚拟路径的路由”例外
我们构建了一个 RouteProvider,将路线数据存储在数据库中。有时(主要是在开发过程中),我们希望重新加载路由表而不必重新启动应用程序。为此,我们在提供者上调用 ReloadRoutes 方法,该方法运行良好,直到我们将 ServiceRoute 添加到 RouteCollection 中。
从那时起,当第二次尝试添加serviceRoute时(在routes.Clear()之后),ServiceRouteHandler会抛出异常。就像 RouteCollection 上的clear方法没有清除全部一样。现在我怎样才能清除服务路由?
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)));
}
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 is 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)));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论