问题描述
路由的需求为.http://www.xxx.com/控制器/动作http://localhost:2207/home/indexhttp://www.xxx.com/控制器/动作/identityhttp://localhost:2207/home/index/9a008b33-baf4-4b60-ae18-10ddbff664d3http://www.xxx.com/控制器/动作/当前页/每页多少个http://localhost:2207/home/List/1http://localhost:2207/home/List/2http://localhost:2207/home/List/3http://localhost:2207/home/List/4已经加上了路由约束..new{Action="Details"}现在只有列表路由出问题了.提示获取不到currentPage这样的需求应该怎么写路由,求指点publicstaticvoidRegisterRoutes(RouteCollectionroutes){routes.IgnoreRoute("{resource}.axd/{*pathInfo}");routes.MapRoute("Home","{Controller}/{Action}",new{Controller="Home",Action="Index"});routes.MapRoute("PhotoDetails","{Controller}/{Action}/{identity}",new{Controller="Home",Action="Details",identity=UrlParameter.Optional},new{Action="Details"});routes.MapRoute("List",//路由名称"{Controller}/{Action}/{currentPage}/{pageSize}",//带有参数的URLnew{Controller="Home",Action="List",currentPage=1,pageSize=20},//参数默认值new{Action="List"});}
解决方案
本帖最后由 lengxiezi1984 于 2011-12-26 12:07:55 编辑
解决方案二:
有人么??高手都去了哪里?
解决方案三:
http://localhost:2207/home/List/1你这没有pagesize啊
解决方案四:
默认加载进去了,没问题的.http://localhost:2207/home/List/1/20路由new{Controller="Home",Action="List",currentPage=1,pageSize=20},pagesize已经加载了.
解决方案五:
这里有个检查路由匹配的组件,开发的时候对路由不熟悉,可以用这个测试下.http://www.cnblogs.com/Capricornus/archive/2010/08/26/1808907.html
解决方案六:
楼上老大,我知道是列表那里出问题拉,我想知道我这样的需求应该怎么写路由..谢谢.
解决方案七:
http://localhost:2207/Article/ListFalseArticle/List/{currentPage}/{pageSize}Controller=Article,Action=List,currentPage=1,pageSize=20Controller=Article,Action=List(null)为什么匹配不上呢?
解决方案八:
路由反过来写,从多到少写.publicstaticvoidRegisterRoutes(RouteCollectionroutes){routes.IgnoreRoute("{resource}.axd/{*pathInfo}");routes.MapRoute("List",//路由名称"{Controller}/{Action}/{currentPage}/{pageSize}",//带有参数的URLnew{Controller="Home",Action="List",currentPage=1,pageSize=20},//参数默认值new{Action="List"});routes.MapRoute("PhotoDetails","{Controller}/{Action}/{identity}",new{Controller="Home",Action="Details",identity=UrlParameter.Optional},new{Action="Details"});routes.MapRoute("Home","{Controller}/{Action}",new{Controller="Home",Action="Index"});}