I would like to create custom slugs for pages in my CMS, so users can create their own SEO-urls (like Wordpress).
I used to do this in Ruby on Rails and PHP framewor
I've edited my answer to give a more complete answer to your questions:
Answer to Question 1:
Registering routes is initialized on startup. (Perhaps also when the Application Pool recycles, it's highly probable.)
I also think there is nothing wrong with your approach since it is occuring only once.
I do the same thing querying all supported languages from the database to register them as /TwoLetterISOLanguageName (/nl, /en, /de, etc.).
Answer to Question 2:
This should work passing a model:
Put it before the Default route!
routes.MapRoute(
name: "Contact",
url: "contact/{action}",
defaults: new { controller = "Contact",
action = "Index",
MyModel = new MyModel { Name = "hello" } });
The ContactController:
public ActionResult Index(MyModel mymodel)
{
return Content(mymodel.Name);
}
The Model:
public class MyModel
{
public string Name { get; set; }
}