jeudi 16 juillet 2015

MapRoute not working as expected

Considering the mapped routes below, when the user goes to /Home, why would the second route be hitting instead of the first? My assumption was that going to /Home would result in the first route being hit, but for some reason the second one is being used.

Why is this?

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapRoute(
          "Home page behind eRaider",
          "Home",
          new { controller = "Home", action = "HomeSecure", id = "" }
        );

        routes.MapRoute(
          "Default",                                              
          "{controller}/{action}/{id}",                           
          new { controller = "Home", action = "Index", id = "" } 
        );
    }

edit: just to be clear, I want /Home to go to the HomeSecure action in the Home controller.

edit2:

        public ActionResult Index()
        {
            return View();
        }

        [AuthorizeHasAccess]
        public ActionResult HomeSecure()
        {
            return View();
        }

Aucun commentaire:

Enregistrer un commentaire