关于Request.PathInfo

今天看到一个帖子《在ASP.NET中重写URL》(http://www.chinaz.com/program/2009/0410/72211.shtml),其中讲到,使用Request.PathInfo 参数实现地址重写。

方法很简单:http://www.store.com/products.aspx/Books,这个链接的接收页面是product.aspx,链接地址的后面“Books”这个参数可以通过Request.PathInfo获取到,这其实是一个参数,然后根据这个参数就可以实现地址重写。

获取方法为:if (Request.PathInfo.Length == 0)
                return "";
            else
                return Request.PathInfo.Substring(1)

因为:Request.PathInfo可以获取具有 URL 扩展名的资源的附加路径信息。  

关于Request.PathInfo的msdn详情:http://msdn.microsoft.com/zh-cn/library/system.web.httprequest.pathinfo(VS.80).aspx  

posted @ 2012-04-26 19:52  日暮乡关何处是  阅读(345)  评论(0编辑  收藏  举报