I have a controller with an action method and I have configured attribute routing:
[RoutePrefix("foos")]
public class FooController : BaseController
{
[HttpGet]
[Route("")]
public ActionResult List()
{
return View();
}
}
Here's routing configuration:
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapMvcAttributeRoutes();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
}
Everything works fine. When I navigate to http://webPageAddress/foo/
my action is called and list is returned.
Now I want to make this route default. I've added new attribute so:
[HttpGet]
[Route("~/")]
[Route("")]
public ActionResult List()
{
return View();
}
The result is default route (http://webPageAddress/
) works, but the old one (http://webPageAddress/foo/
) doesn't work anymore (http 404 code).
How can I mix it and have both configured properly?