开发者

Problem passing parameters in asp.net mvc2

开发者 https://www.devze.com 2022-12-25 04:40 出处:网络
I have the following controller: public ActionResult Search(string Name, int? Friend, int? Page) It works if I use this url localhost/users/search/name but 开发者_开发知识库these don\'t localhost/us

I have the following controller:

public ActionResult Search(string Name, int? Friend, int? Page)

It works if I use this url localhost/users/search/name but 开发者_开发知识库these don't localhost/users/search/name/1 and localhost/users/search/name/1/1


You have to define additional route:

routes.MapRoute(
                "UsersSearch",                                              // Route name
                "users/search/{name}/{friend}/{page}",                           // URL with parameters
                new { controller = "Users", action = "Search" }  // Parameter defaults
            );


routes.MapRoute(
                "UsersSearch",                                              // Route name
                "users/search/{name}/{friend}",                           // URL with parameters
                new { controller = "Users", action = "Search" }  // Parameter defaults
            );
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号