0

我已经注册了这条路线:

context.MapRoute(
                "Book",
                "book/{id}",
                new { action = "index", controller = "book" },
                new string[] { "Web.Areas.Books.Controllers" }
            );

这提供这样的网址:http:///book/4f6be481e8f6ae0a9063afe7

现在我有一个网址,它是以下之一:

http://<domain>/book/4f6be481e8f6ae0a9063afe7/GetFullDescription?app=3
OR
http://<domain>/book/GetFullDescription?app=3&id=4f6be481e8f6ae0a9063afe7

我更喜欢第一条路线。我就是不能让它工作。我在图书控制器中定义了一个动作 GetFullDescription。

如果我注册这样的路线,它会进入 GetFullDescription 操作。

context.MapRoute(
                "BookFullDesc",                
                "book/{action}/{id}",                
                new { action = "index", controller = "book", id = UrlParameter.Optional },
                new string[] { "Web.Areas.Books.Controllers" }
            );

但是http://<domain>/book/4f6be481e8f6ae0a9063afe7网址中断了

除非我将其更改为 http://<domain>/book/index/4f6be481e8f6ae0a9063afe7<-- 注意索引后的索引

编辑: 我想要的只是一条同时服务这两个 URL 的路线:

http://<domain>/book/4f6be481e8f6ae0a9063afe7
http://<domain>/book/4f6be481e8f6ae0a9063afe7/GetFullDescription

谢谢

4

1 回答 1

0
context.MapRoute(
                "Book",
                "book/{id}/{action}",
                new { action = "index", controller = "book", app = 3 },
                new string[] { "Web.Areas.Books.Controllers" }
            );
于 2013-05-12T05:01:04.473 回答