Route click to controller

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 năm cách đây
Hi All,

I've added some code to the CatalogController.cs to say:

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

I've got a forced link using:

<a href="@Url.RouteUrl("ProductGridList", new { categoryId = 8, SeName = "collections" })">Test</a>

Which I want to call the actionresult from so, I've added the route using:

routes.MapLocalizedRoute("ProductGridList",
                            "c/{categoryId}/{SeName}",
                            new { controller = "Catalog", action = "ProductGridList", SeName = UrlParameter.Optional },
                            new { categoryId = @"\d+" },
                            new[] { "Nop.Web.Controllers" });

Now, why does it ALWAYS call the Category actionresult? Why won't it call the productgridlist?
11 năm cách đây
we have already the same combination for category route. so it'll fetch the first route. so your new route will be ignored.

replace c by any other word here i am using pgl.

routes.MapLocalizedRoute("ProductGridList",
                            "pgl/{categoryId}/{SeName}",
                            new { controller = "Catalog", action = "ProductGridList", SeName = UrlParameter.Optional },
                            new { categoryId = @"\d+" },
                            new[] { "Nop.Web.Controllers" });
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.