ASP.NET Web Forms URL Rewriting capability

谁都会走 提交于 2019-12-23 02:50:36

问题


I have a very simple question, rather I am just curious.

I have about 2000 pages of the url format somewebsite.com/ShowProduct.aspx?ID=223 . This particular url has a page title as 'Walking sticks for elders made from durable steel'.

Can I use URL Rewriting to convert this to a url like somewebsite.com/walking-stick-for-elders ? Also will I have do it dynamically for 2000 pages or is there any expression that can be used?


回答1:


You need to have some thing which uniquely indentifies URLs just like Stackoverflow does it.

ASP.NET Web Forms URL Rewriting capability

See this question URL - Where from URL you get its for question then there is a question id and then description. I suggest you do the same.

If you are using ASP.NET 4.0 or higher version then you can do that type of URL routing very easily.

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

There is also a asp.net friendly URL package form where you can write URls.

http://www.hanselman.com/blog/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx

RouteConfig.RegisterRoutes(RouteTable.Routes);



回答2:


If each product name is unique and stored inside the database you can easily route each SEO friendly URL to productID without manually inputing a new route in the Routing table.



来源:https://stackoverflow.com/questions/29787153/asp-net-web-forms-url-rewriting-capability

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!