今天在看.NET 3.5 SP1的一些新增特性,其中提到了一个Routing组件,这个专门用来做URL重定向的组件,已经被使用在最新的ASP.NET MVC以及ASP.NET Dynamic Data Web App中。这让我不由得想起来几年的另外一个组件,叫做URLRewriting。
http://msdn.microsoft.com/zh-cn/library/ms972974.aspx
既然Routing组件很不错,那么在传统的WebForms的场景下能不能用呢?答案是:可以,但要特别小心,和很有耐心
http://msdn.microsoft.com/en-us/magazine/2009.01.extremeaspnet.aspx。
http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx
我个人觉得还是直接用URLRewriting就好了。
两者的比较主要如下
This is one key difference between Routing and URL Rewriting, routing doesn’t actually rewrite the URL. Another key difference is that routing provides a mean to generate URLs as well and is thus bidirectional.