C# 从数据库在routeconfig中动态生成路由

C# 从数据库在routeconfig中动态生成路由,c#,asp.net-mvc,wcf,asp.net-mvc-routing,C#,Asp.net Mvc,Wcf,Asp.net Mvc Routing,我的数据库表中存储了一些路由,如下所示: /Customer/{Customer}/Address /Customer/{Customer}/Address/{Address} 以上只是例子,因为我可以有更多的路线也 现在,我想通过从下面routeconfig中的数据库获取,在routeconfig中动态生成路由: public class RouteConfig { public static void RegisterRoutes(RouteCollection r

我的数据库表中存储了一些路由,如下所示:

/Customer/{Customer}/Address
/Customer/{Customer}/Address/{Address}
以上只是例子,因为我可以有更多的路线也

现在,我想通过从下面routeconfig中的数据库获取,在routeconfig中动态生成路由:

public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            //I am thinking to generate my routes dyncamically here.
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
            );
        }
    }

所以我的问题是这个解决方案有多可行,如果可行的话,我们可以在wcf中做同样的事情吗???

为什么你想让它们来自db?@NikhilVartak:我们有一个界面,用户可以在其中创建这些端点,以便用户何时调用这些端点(用户想要多少端点)我想实现一些逻辑并返回一个响应。用户可以创建任意多个路由,并且每个路由都会有一个与该路由相关联的sql查询。因此,当该路由到达时,我希望执行该sql查询并将响应返回给用户。希望这样做有意义。@NightOwl888:感谢您提供的信息,但这可能吗在我的应用程序运行时将路由添加到routestable??