Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 路由RouteValueDictionary url作为第二项问题_C#_Asp.net_C# 4.0_Routing - Fatal编程技术网

C# 路由RouteValueDictionary url作为第二项问题

C# 路由RouteValueDictionary url作为第二项问题,c#,asp.net,c#-4.0,routing,C#,Asp.net,C# 4.0,Routing,我在将URL作为RouteValue项发送和使用参数获取GetVirtualPath时遇到问题 var parameters = new RouteValueDictionary { { CommonUrl.UrlParameters.AnyString, "ItISAnyString"}, {CommonUrl.UrlParameters.ReturnUrl, "test/myPage/Index"} }; 并使用以下参数获取URL: RouteTa

我在将URL作为RouteValue项发送和使用参数获取GetVirtualPath时遇到问题

 var parameters = new RouteValueDictionary { 
       { CommonUrl.UrlParameters.AnyString, "ItISAnyString"},
       {CommonUrl.UrlParameters.ReturnUrl, "test/myPage/Index"}   
  };
并使用以下参数获取URL:

RouteTable.Routes.GetVirtualPath(null, anyRouteName, **parameters**).VirtualPath
所以我得到的URL像test/myPage/Index

系统尚未识别此页面和sad 404。 但是如果我手动执行类似的操作
测试$myPage$Index 一切正常。 我认为应该有更好的办法来解决这个问题

编辑

我发现这条路线没有任何RouteValueDictionary。我认为,如果有多个“/”符号,则路由不会取消第二个参数的链接。所以我会创造它,看看会发生什么

编辑

我的大学很遗憾,当我把URL作为参数发送时,我不得不对它进行编码。 好的,我做到了。 但现在我有400个错误。
这对我来说有点奇怪。

问题在于映射模式。 我刚刚在路线图中添加了{*}模式。 现在,我的global.asax代码:

routes.MapPageRoute(RouteName.Security.TestOne,
                                            Test, 
                                            "~/Web/Pages/Test/test.aspx", true);

  public static string Test = String.Format("{0}/{1}/{2}/{3}",
                                                                            "Test",
                                                                            "Testconfirm",
                                                                            "{" + CommonUrl.UrlParameters.FirstParam+ "}",
                                                                            "{*****" + CommonUrl.UrlParameters.Url + "}");
此概念名称为“在URL模式中处理可变数量的段”