Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I modify an MVC route outside of Global.asax?

Is it possible to modify the the routes (and thus the RouteTable) outside of the global.asax file, maybe in a controller? Is this even advisable?

My reason for asking has to do with IIS 6 and Integrated Mode not allowing for Request context calls. I'm implementing internationalization for a site and keeping track of the culture in the URL. The culture is originally read from a .config file and loaded as a route default. This file read is what ends up throwing the error (another few steps up the stack). I based this off the method described here.

like image 302
Collin M Avatar asked Jul 20 '11 15:07

Collin M


1 Answers

You can access the routing table pretty much anywhere like so System.Web.Routing.RouteTable.Routes, have tested this from a controller and it worked fine.

like image 175
Stuart Avatar answered Sep 24 '22 02:09

Stuart