2

I have some routes store in my database tables like below :

/Customer/{Customer}/Address
/Customer/{Customer}/Address/{Address}

Above are just examples as i can have more routes also.

Now i want to generate routes dynamically in routeconfig by fetching from database in below 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 }
            );
        }
    }

So my question is how feasible this solution will be and if it is feasible then can we do same thing in wcf??

ILoveStackoverflow
  • 2,409
  • 1
  • 17
  • 37
  • And why do you want them to come from db? – Nikhil Vartak Apr 12 '17 at 14:34
  • @NikhilVartak:We have an interface where user can create those endpoints so when user will call those end points(as many end points as user wants) i want to implement some logic and return a response.User can create as many routes as they want and with each route there will be an sql query associated with that route.So when that route will hit then i would like to execute that sql query and return response to user.hope that make sense – ILoveStackoverflow Apr 12 '17 at 14:37
  • http://satvasolutions.com/url-routing-database-driven-url-asp-net-mvc-website/ – Nikhil Vartak Apr 12 '17 at 14:40
  • See [this answer](http://stackoverflow.com/a/31958586/181087). – NightOwl888 Apr 13 '17 at 07:37
  • @NightOwl888 :thanks for the info but is it possible to add routes to routestable when my application is running?? – ILoveStackoverflow Apr 13 '17 at 09:56

0 Answers0