C# ASP.NET MVC 4某些路由不工作

C# ASP.NET MVC 4某些路由不工作,c#,asp.net-mvc-4,C#,Asp.net Mvc 4,路线: 测试URL1:(确实有效) customer/widget/contact_list/1-1004-SC-0-0-0-0-0-Supplier-Supplier----0-0-0-0-Year-Calendar-0-Home-0 测试URL2:(不工作) 我已经测试了上面的两个URL。第一个URL指向正确的位置。但是第二个URL迷失了方向。。。 我不知道这是什么原因。。。 我有点假设白天部分,6%2f1%2f2013-7%2f6%2f2013,会导致一些问题,但我不确定这是什么 客户控制

路线:

测试URL1:(确实有效)
customer/widget/contact_list/1-1004-SC-0-0-0-0-0-Supplier-Supplier----0-0-0-0-Year-Calendar-0-Home-0

测试URL2:(不工作)

我已经测试了上面的两个URL。第一个URL指向正确的位置。但是第二个URL迷失了方向。。。 我不知道这是什么原因。。。 我有点假设白天部分,6%2f1%2f2013-7%2f6%2f2013,会导致一些问题,但我不确定这是什么

客户控制器

customer/widget/contact_list/1-1004-SC-0-0-0-0-0-0-Supplier-Supplier--6%2f1%2f2013-7%2f6%2f2013--0-0-0-0-Year-Calendar-0-Home-0  (does not work) 
 public ActionResult Index(string id = null)
    {
      string temp = "~/customer/widget/contact_list/" + this.objURL.ToString();
      return Redirect("~/customer/widget/contact_list/" + this.objURL.ToString());
    }
客户控制器

customer/widget/contact_list/1-1004-SC-0-0-0-0-0-0-Supplier-Supplier--6%2f1%2f2013-7%2f6%2f2013--0-0-0-0-Year-Calendar-0-Home-0  (does not work) 
 public ActionResult Index(string id = null)
    {
      string temp = "~/customer/widget/contact_list/" + this.objURL.ToString();
      return Redirect("~/customer/widget/contact_list/" + this.objURL.ToString());
    }

flow CustomerController->(按地图路径)Customer\u WidgetController

这都是因为编码的斜杠“%2f”符号对应于“/”。因为这是你的网址

customer/widget/contact_list/1-1004-SC-0-0-0-0-0-0-Supplier-Supplier--6%2f1%2f2013-7%2f6%2f2013--0-0-0-0-Year-Calendar-0-Home-0  (does not work) 
 public ActionResult Index(string id = null)
    {
      string temp = "~/customer/widget/contact_list/" + this.objURL.ToString();
      return Redirect("~/customer/widget/contact_list/" + this.objURL.ToString());
    }
  public ActionResult Contact_list(string id = null)
    {
      return PartialView("_contact_list",Customer_Widget.Contact_list.Load(id, ref errors));
    }
分成8个部分:

  • 顾客
  • 小部件
  • 联络人名单
  • 1-1004-SC-0-0-0-0-0-Supplier-Supplier--6
  • 一,
  • 2013-7
  • 六,
  • 2013年——0-0-0-0-0-Year-Calendar-0-Home-0
  • 但在你的路线上,你期待着4

    要定义段的可变计数,可以使用星号(*),如下所示:

    customer/widget/contact_list/1-1004-SC-0-0-0-0-0-0-Supplier-Supplier--6%2f1%2f2013-7%2f6%2f2013--0-0-0-0-Year-Calendar-0-Home-0
    
    路由系统按顺序检查路由。所以,您需要小心,并尽可能低地定义这样的路由,因为它可以捕获您不希望使用此路由捕获的请求。例如,如果在您的系统中定义了以下路由,则将永远不会捕获上面的路由:

    routes.MapRoute(
        "Customer_widget",
        "customer/widget/{action}/{*id}",
        new { controller = "Customer_Widget", id = UrlParameter.Optional });