相同的网址在asp.net网络路由两页 [英] Same url for two pages in asp.net web routing
问题描述
我的工作网页URL路由。我想以同样的没有两个路径URL。参数,相同的模式和相同的URL,但不同的路线名称。
我的路线如下。
I am working on web page url routing. I want two route url with equal no. parameters, same pattern and same url but different route name. My routes are below.
Routes.MapPageRoute("Route1", "{parameter1}/{parameter2}", "packages.aspx");
Routes.MapPageRoute("Route2", "{parameter1}/{parameter2}", "destination.aspx", false, null, null,new RouteValueDictionary { { "isDestination", "yes"} });
当我打电话的虚拟路径数据,我只在重定向是全球文件上面写的网址。
When I call virtual path data, I am only redirecting on url that is written on top of global file.
VirtualPathData vpd =RouteTable.Routes.GetVirtualPath(null,
"Route1",
"parameter1", "parameter2");
VirtualPathData vpd =RouteTable.Routes.GetVirtualPath(null,
"Route2",
"parameter1", "parameter2");
有关ROUTE1 Vpd的回路。
我怎样才能既构建了网址两个不同的页面?
Vpd return route for Route1. How can I construct both url for two different pages?
推荐答案
第一个选项:您使用的路由约束来限制匹配特定的路线,浏览器的请求。您可以使用常规的前pression指定一个路由约束。
First Option: You use route constraints to restrict the browser requests that match a particular route. You can use a regular expression to specify a route constraint.
第二个选项::您可以使用恒定参数你的路由具有相同数量和放大器之间的区别;类型的参数。
Second Option: You can use constant parameter to distinguish between your routes which have same number & type of parameters.
例如:
Routes.MapPageRoute("Route1", "packages/{parameter1}/{parameter2}", "packages.aspx");
Routes.MapPageRoute("Route2", "destination/{parameter1}/{parameter2}", "destination.aspx", false, null, null,new RouteValueDictionary { { "isDestination", "yes"} });
这篇关于相同的网址在asp.net网络路由两页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!