Using Both of Attribute and Convention Routing
<p>Is there a way to use Convention and Attribute Routing together?
I want to call an action method with the real name of method and controller when I defined the attribute routing.</p>

<p>The mapping method is calling at startup:</p>

<pre><code>public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapMvcAttributeRoutes();///
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
</code></pre>

<p>Here is the controller:</p>

<pre><code>[RoutePrefix("d")]
[Route("{action=index}")]
public class DefaultController : Controller
{
    [Route]
    public ActionResult Index()
    {
        return View();
    }

    [Route("f")]
    public ActionResult Foo()
    {
        return View();
    }
}
</code></pre>

<p>I can reach to Foo action method with <code>/d/f</code> url. But when I try this url: <code>/Default/Foo</code>, the 404 error occurs. Actually it throws the action not found exception which it says like <code>A public action method 'Foo' was not found on controller 'Namespace...DefaultController'.</code></p>

<p>I checked the source code of asp.net mvc and I saw these lines:</p>

<pre><code>if (controllerContext.RouteData.HasDirectRouteMatch())
{
    ////////
}
else
{
    ActionDescriptor actionDescriptor = controllerDescriptor.FindAction(controllerContext, actionName);
    return actionDescriptor;
}
</code></pre>

<p>It checks if there is a direct route or not, which the <code>/Default/Foo</code> route is not a direct route so it should act as convention routing which is registered at startup as <code>{controller}/{action}/{id}</code>. But it doesn't find the action with <code>controllerDescriptor.FindAction</code> method and it throws the exception.</p>

<p>Is this a bug or cant I use both routing methods together? Or are there any workaround to use both?</p>

<h3>Edit</h3>

<p>I debugged into mvc source code, and I saw these lines:</p>

<pre><code>namespace System.Web.Mvc
{
    // Common base class for Async and Sync action selectors
    internal abstract class ActionMethodSelectorBase
    {
        private StandardRouteActionMethodCache _standardRouteCache;

        protected void Initialize(Type controllerType)
        {
            ControllerType = controllerType;

            var allMethods = ControllerType.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public);
            ActionMethods = Array.FindAll(allMethods, IsValidActionMethod);

            // The attribute routing mapper will remove methods from this set as they are mapped.
            // The lookup tables are initialized lazily to ensure that direct routing's changes are respected.
            StandardRouteMethods = new HashSet&lt;MethodInfo&gt;(ActionMethods);
        }
</code></pre>

<p>The last comments about attribute routing explains why this problem happens. The Attribute routing removes <code>StandardRouteMethods</code> when you call <code>MapMvcAttributeRoutes</code>. </p>

<p>I'm still seeking a workaround.</p>