sina.islam wrote:If you want to override "cart" without increase priority.You can use this code
var route = routes.CustomMapLocalizedRoute("Plugin.Misc.MyPlugin.ShoppingCartUrl",
"cart/",
new { controller = "ShoppingCart", action = "Cart" },
new[] { "Nop.Plugin.Misc.MyPlugin.Controllers" });
routes.Remove(route);
routes.Insert(0, route);
It works for me.
Some people ask me about CustomMapLocalizedRoute.
Here is the Class :
using System;
using System.Web.Mvc;
using System.Web.Routing;
namespace Nop.Plugin.Misc.AvenirTelecom
{
public static class LocalizedRouteExtensions
{
//Override for localized route
public static Route CustomMapLocalizedRoute(this RouteCollection routes, string name, string url, object defaults, string[] namespaces)
{
return MapLocalizedRoute(routes, name, url, defaults, null /* constraints */, namespaces);
}
public static Route MapLocalizedRoute(this RouteCollection routes, string name, string url, object defaults, object constraints, string[] namespaces)
{
if (routes == null)
{
throw new ArgumentNullException("routes");
}
if (url == null)
{
throw new ArgumentNullException("url");
}
var route = new LocalizedRoute(url, new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(defaults),
//Constraints = new RouteValueDictionary(constraints),
DataTokens = new RouteValueDictionary()
};
if ((namespaces != null) && (namespaces.Length > 0))
{
route.DataTokens["Namespaces"] = namespaces;
}
routes.Add(name, route);
return route;
}
public static void ClearSeoFriendlyUrlsCachedValueForRoutes(this RouteCollection routes)
{
if (routes == null)
{
throw new ArgumentNullException("routes");
}
foreach (var route in routes)
{
if (route is LocalizedRoute)
{
((LocalizedRoute) route).ClearSeoFriendlyUrlsCachedValue();
}
}
}
}
}