I am receiving an IIS 404 error message when I try to go to the index method in my home controller in the agency
area. If I update the route
attribute to: [Route("{action}")]
it works fine, but I want to keep index
as the default route.
In my view I have this:
@Html.ActionLink("Click here", "index", "home", new { area = "agency" }, new { @class = "btn btn-block btn-lg btn-primary" })
HomeController in Agency Area
namespace ProjectName.UI.Areas.Agency.Controllers
{
[RouteArea("agency")]
[RoutePrefix("home")]
[Route("{action=index}")]
public class HomeController : BaseController
{
public ActionResult Index()
{
return View();
}
}
}
RouteConfig:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
AreaRegistration.RegisterAllAreas();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "home", action = "index", id = UrlParameter.Optional },
namespaces: new[] { "ProjectName.UI.Controllers" }
);
}
I also have an Admin Area that looks exactly the same as the Agency area, except the RouteArea
is admin
and I don't have any problems.
Any suggestions would be welcomed.