当前位置:编程学习 > C#/ASP.NET >>

mvc中,MapRoute如何将url:http://xxx.com/list/readlist/1,写成http://xxx.com/list/1

http://xxx.com/bbslist/readlist/1
解释一下:
http://xxx.com/ 是网站
bbslist 是controller(论坛帖子的列表)
readlist 是action,list controller中的一个actionResult
1 是分页的页码

目前生成的url太难看了!!!
能不能就直接生成http://xxx.com/bbslist/1 也就是说,不显示action
或者是http://xxx.com/readlist/1,也就是说不显示controller


我在下面试了,但是不行!
Public Shared Sub RegisterRoutes(ByVal routes As RouteCollection) 
        routes.MapRoute(
            name:="bbs",
            url:="{controller}/{action}/{id}",
            defaults:=New With {.controller = "bbslist", .action = "readlist", .id =UrlParameter.Optional})

End Sub

补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,