Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset the asp.net mvc routes without resetting the app

I want to stroe my routes in DB and register them in Application_Start of Global.asax.cs. Everything is fine but any change in the DB, I have to reset the app in order to let app to pick up my changes.

If i can reset the routes without restart the app, the problem will be solved. How would I achive it geeks? A custom httpmodule? or...

like image 230
ldsenow Avatar asked Nov 05 '22 20:11

ldsenow


1 Answers

public static void UpdateRouteRegistration() {
  RouteCollection routes = RouteTable.Routes;
  using (routes.GetWriteLock()) {
    routes.Clear();
    // repopulate route table here
  }
}

Then call this method from Application_Start and any other time you need to initialize the route table. Note: This is from memory and might be slightly mistyped, but you get the idea. :)

like image 88
Levi Avatar answered Nov 15 '22 11:11

Levi