开发者

Routing RouteValueDictionary url as second item problem

I have a problem with send URL as RouteValue item and get GetVirtualPath with one`s parameter.

 var parameters = new RouteValueDictionary { 
       { CommonUrl.UrlParameters.AnyString, "ItISAnyString"},
       {CommonUrl.开发者_Go百科UrlParameters.ReturnUrl, "test/myPage/Index"}   
  };

And get URL with this parameters:

RouteTable.Routes.GetVirtualPath(null, anyRouteName, **parameters**).VirtualPath

So I get URL like http://localhost/ItISAnyString/test/myPage/Index

System haven`t recognized this page and sad 404. But if I manually do something like this

http://localhost/ItISAnyString/test$myPage$Index All work fine. I think should exist better way to resolve this problem.

Edit

I found that for this Route dont exist any RouteValueDictionary. I think that routing dont undestend second parameter if there is more that one '/' symbol. So I will create it and see what hapens.

Edit

My college sad that I have to encode URL when send it as parameter. Ok, I did it. But now I have 400 error. It`s a bit strange, as for me.


Problem was in the mapping pattern. I have just added {*} pattern to the route maps. Now my global.asax code:

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 + "}");

This concept name is "Handling a Variable Number of Segments in a URL Pattern" http://msdn.microsoft.com/en-us/library/cc668201.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜