I have a number of URLs that fit a {controller}/{action} pattern.
My problem is that I want to use multiple, dash-separated words for the second parameter (action). Since dashes are not allowed in action-method names, I cannot map this pattern with just one mapping, and I must resort to a new mapping for each new action, like this:
routes.MapRoute(
"ContactUsForm", "forms/contact-us", new {
action = "contact_us",
controller = "Forms"
});
I have many forms that need this pattern, and their concerns are different enough that I cannot map them to the same action-method.
QUESTION
Is there a simple way around this, say some way to map {controller}/{some-string} to the action “some_string”, and route all of my form URLs in one go?
You can specify action name in the attribute and use it without any changes in routes: