本文介绍了webforms asp.net 4.0的URL路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



想要创建如下所示的路线。



1)www .abc.com /搜索地图到https://www.abc.com/abc/Search.aspx。



2)www.abc.com/information maps https://www.abc.com/abc/Information.aspx



3)www.abc.com/poplist maps https://www.abc.com /abc/List.aspx?item=pop。



我已经通过了friendlyURLS,但它没有达到目的

和通过以下链接:



http://msdn.microsoft.com/en-us/library/cc668177(v=vs.100).aspx



尝试以下内容:



RegisterRoutes(RouteTable.Routes);



void RegisterRoutes(RouteCollection路线)

{





RouteTable.Routes.MapPageRoute (SearchRoute,

{Name},

〜/ abc / Search.aspx);



RouteTable.Routes.MapPageRoute(InfoRoute,

{Info},

〜/ abc / Information.aspx);



RouteTable.Routes.MapPageRoute(SearchRoute,

{List},

〜/ abc / List.aspx);

}



它只前往搜索页面。

你能否解释一下我错过了什么?



最好的问候,

Damodar

Hi All,

Wanted to create routes as shown in following .

1) www.abc.com/search maps to https://www.abc.com/abc/Search.aspx.

2) www.abc.com/information maps https://www.abc.com/abc/Information.aspx

3) www.abc.com/poplist maps https://www.abc.com/abc/List.aspx?item=pop.

I've gone through friendlyURLS but it doesn't serve the purpose
and gone through following link:

http://msdn.microsoft.com/en-us/library/cc668177(v=vs.100).aspx

And tried following:

RegisterRoutes(RouteTable.Routes);

void RegisterRoutes(RouteCollection routes)
{


RouteTable.Routes.MapPageRoute("SearchRoute",
"{Name}",
"~/abc/Search.aspx");

RouteTable.Routes.MapPageRoute("InfoRoute",
"{Info}",
"~/abc/Information.aspx");

RouteTable.Routes.MapPageRoute("SearchRoute",
"{List}",
"~/abc/List.aspx");
}

It is heading to search page only.
Can you please shed some light what am I missing?

Best Regards,
Damodar

推荐答案

http://weblogs.asp.net/scottgu/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series

[ ^ ]


这篇关于webforms asp.net 4.0的URL路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 23:45