Current ASAX code (simplified):
void Application_Start(object sender, EventArgs e)
{
// Enable routing
RegisterRoutes(RouteTable.Routes);
}
void RegisterRoutes(RouteCollection routes)
{
routes.Add("ContactUsRoute",
new Route("contact-us",
new PageRouteHandler("~/contactus.aspx")));
}
Question
Is it safe to pull routes from the DB at this point? For example:
void RegisterRoutes(RouteCollection routes)
{
routes.Add("ContactUsRoute",
new Route("contact-us",
new PageRouteHandler("~/contactus.aspx")));
// BusinessLogic.GetPageRoutes() returns a List<Route>
var dbRoutes = BusinessLogic.GetPageRoutes();
foreach (Route route in dbRoutes)
{
routes.Add(route);
}
}
Additional Information
This question is born out of a lack of knowledge concerning routing as well as a general unfamiliarity with global.asax
. In the past, I've only used global.asax
for extremely simple tasks; DB feels like I'm taking it to another level.