How to remove a MVC Route

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi,

I'm building my own check-out & register logic.
So for this I have my own IRouteProvider implementation and it works.
However once in a while I get things like:

Exception message: A route named 'Register' is already in the route collection. Route names must be unique.

How can I fixed this ?

public class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(RouteCollection routes)
        {

            routes.Remove(routes["CustomerMyAccount"]);
            routes.Remove(routes["CustomerInfo"]);
            routes.Remove(routes["Register"]);
            routes.Remove(routes["RegisterResult"]);


            routes.MapLocalizedRoute("CustomerMyAccount",
                "customer/myaccount",
                new { controller = "xxxCustomer", action = "MyAccount" },
                new[] { "Nop.Plugin.xxx" });
            
            routes.MapLocalizedRoute("CustomerInfo",
                "customer/info",
                new { controller = "xxxCustomer", action = "Info" },
                new[] { "Nop.Plugin.xxx" });

            routes.MapLocalizedRoute("Register",
                "register/",
                new { controller = "xxxCustomer", action = "Register" },
                new[] { "Nop.Plugin.xxx" });
            routes.MapLocalizedRoute("RegisterResult",
                "registerresult/{resultId}",
                new { controller = "xxxCustomer", action = "RegisterResult" },
                new { resultId = @"\d+" },
                new[] { "Nop.Plugin.xxx" });

        }

        public int Priority
        {
            get { return 0; }
        }
    }


What does Priority do ?
12 years ago
Nevermind...
Setting the priority to -1 does the trick.
(sorry)
12 years ago
In my case this works only on my development machine, but on the production server the plugin's routes are never called...any idea?
12 years ago
solved, I didn't noticed the shadow copy folder of the plugins was not cleared on application start-up!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.