You can use a routehandler.
public class HyphenatedRouteHandler : MvcRouteHandler
{
protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
{
requestContext.RouteData.Values["controller"] = requestContext.RouteData.Values["controller"].ToString().Replace("-", "_");
try
{
requestContext.RouteData.Values["action"] = requestContext.RouteData.Values["action"].ToString().Replace("-", "_");
}
catch { }
return base.GetHttpHandler(requestContext);
}
}
..and add it to your route like this:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
).RouteHandler = new HyphenatedRouteHandler();
This will mean that, whenever you have a controller named "Example_Controller" with an action called "Example_Action", you will be able to call it with /example-controller/example-action