Search code examples
c#asp.netasp.net-mvcroutesasp.net-mvc-5

Using MVC5's RoutePrefix with areas


I currently have a controller which is located at /account/signin. How can I use MVC5's RoutePrefix to make it addressable at /account/sign-in?

I've tried decorating my controller:

[RoutePrefix("account/sign-in")]
public class SignInController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
}

and mapping my routes in RegisterRoutes:

routes.MapMvcAttributeRoutes();

but I get this exception when doing so:

The controller for path '/account/sign-in' was not found or does not implement IController


Solution

  • I deleted my default routing file (AccountAreaRegistration.cs) and it's now working. I didn't realise you can't use both!