Unable to invoke controller action in Theme

Topics: Troubleshooting, Writing themes
Oct 10, 2015 at 7:49 AM
I am attempting to build an admin controller in a theme. That's a bit unusual so I'll explain. I want to enable the site administrator be able to duplicate a Bootstrap Swatch. I display a list of swatches and allow the user to select one and click 'Duplicate'. So I have a simple controller in the theme (which is also a proper VS Project located in Themes, not Themes/Themes) and I have also configured a route.
namespace Cascade.Bootstrap.Controllers
{
    public class BootstrapSettingsController : Controller
    {
        public ILogger Logger { get; set; }

        public BootstrapSettingsController()
        {
            Logger = NullLogger.Instance;
        }

        [HttpPost]
        [AlwaysAccessible]
        [ValidateInput(false)]
        public ActionResult DuplicateSwatch()
        {
            // duplicate the swatch

            Logger.Information("DuplicateSwatch");

            // Redirect the user to the Index action
            return RedirectToAction("Index");

        }
    }
}
And here is the route:
namespace Cascade.Bootstrap
{
    public class Routes : IRouteProvider
    {
        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (var routeDescriptor in GetRoutes())
                routes.Add(routeDescriptor);
        }

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            return new[] {
                new RouteDescriptor {   
                    Priority = 5,
                    Route = new Route("Admin/Settings/CascadeBootstrapTheme/DuplicateSwatch",
                        new RouteValueDictionary {
                            {"area", "Cascade.Bootstrap"},
                            {"controller", "BootstrapSettings"},
                            {"action", "DuplicateSwatch"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "Cascade.Bootstrap"}
                        },
                        new MvcRouteHandler())
                }
            };
        }
    }
}
Looking at it in the debugger, the DuplicateSwatch() action is never invoked.

However, if I set a breakpoint in OrchardControllerFactory, it breaks and the values look correct to me:
controllerName  "BootstrapSettings" string
areaName    "Cascade.Bootstrap" string
serviceKey  "cascade.bootstrap/bootstrapsettings"   string
I have written heaps of Orchard Controllers and can't remember having a problem like this before. It has to be something hideously simple, but I just can't see it. Can anybody help?
Oct 11, 2015 at 4:02 AM
Mea culpa. I was trying to test a POST with a GET. It works just fine.

If this happens to you then it's time to take a break. The answer will be obvious when you return:-)
Marked as answer by bsdr on 10/10/2015 at 8:02 PM