0

I am having 1 interface from where user can create end points like below :

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

As i understand that routing is added to routing table at the start of application i.e when Application_Start event of global.asax is fired.

Now when user will add this routes is it possible to add this routes to routingtable without restarting application.

When user will add those end points and try to call those end points when my application is running they should be able to call those end points and those end points will be responsible to return some responses.

So is this possible??

I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216
  • http://stackoverflow.com/questions/4849156/how-can-i-dynamically-add-to-the-asp-net-mvc-routetable – DavidG Apr 13 '17 at 10:42
  • @DavidG:But is this possible when my application is running like how can i reference routingtable from any action method where my end points are getting saved? – I Love Stackoverflow Apr 13 '17 at 10:46
  • You could access it like this: `System.Web.Routing.RouteTable.Routes.MapRoute()` like you do inside `RouteConfig`, which commonly resides in your `App_Start` folder, but you can access this inside your action method. – Alisson Reinaldo Silva Apr 13 '17 at 11:19
  • @Alisson :but is it possible to add new routes to routing table when application is running? – I Love Stackoverflow Apr 13 '17 at 11:23
  • @User I've never tried myself, but I'd guess there is no problem in doing that. – Alisson Reinaldo Silva Apr 13 '17 at 11:27
  • Adding routes to the route table is possible, but anti-pattern. This [cannot even be done anymore in AspNetCore](https://stackoverflow.com/a/32586837/181087). Instead, you should create a route that you can add URLs to dynamically. See [Multiple levels in MVC custom routing](https://stackoverflow.com/a/31958586/181087). – NightOwl888 Jul 14 '17 at 16:59

0 Answers0