如何修改MVC中的url

时间:2017-03-27 09:22:16

标签: asp.net-mvc url url-rewriting

我需要更改MVC网站的网址。网址如下所示:

Product/SubCategories/14?selected=ARO-240-244-2.7 D&category=Suspensie %2F Directie&engineId=33497

我需要网址中的所有这些信息,只有没有"选择="," category ="," engineId ="。分隔符应为" /",而不是"&" 它应该是这样的:

Product/SubCategories/14?ARO-240-244-2.7 D/Suspensie %2F Directie/33497

你能告诉我如何实现这个目标吗? 在视图中我有这个:

<a href="@Url.Action("SubCategories", "Product", new { selected = selected, id = @c.ID, category = @c.CategoryName, engineId = engineId }, Request.Url.Scheme)" class="list-group-item bg-success">

我使用这条路线:

  routes.MapRoute(
         "Childrens",                                           // Route name
         "{controller}/{action}/{id}",                            // URL with parameters
          new { controller = "Product", action = "SubCategories" }  // Parameter defaults
      );

谢谢!

0 个答案:

没有答案