1

我的 mvc 应用程序中有多个路由。我想知道应用程序中的多个路由对性能不利吗?

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                "Faq",
                "Faq/{action}",
                new { controller = "Faq", action = "Index" }
                );
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                "PostArchive",
                "Post/{action}",
                new { controller = "Post", action = "PostArchive" }
                );
            routes.MapRoute(
                "LogOn",
                "Account/{action}",
                new { controller = "Account", action = "LogOn" }
                );
            routes.MapRoute(
                "Localization",
                "{lang}/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional, lang = UrlParameter.Optional } // Parameter defaults
                );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}/{Name}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, name = UrlParameter.Optional },
                namespaces: new[] { "MVCTemplateProject.Controllers" }
                );

            routes.MapRoute(
                name: "Post",
                url: "{lang}/{controller}/{action}/{id}/{Title}",
                defaults: new { controller = "Post", action = "Index", id = UrlParameter.Optional, Title = UrlParameter.Optional },
                namespaces: new[] { "MVCTemplateProject.Controllers" }
                );
4

2 回答 2

0

Sam Saffron 写了一篇关于路由性能的有趣博客文章 - 特别是使用正则表达式约束的路由以及路由的排序。绝对值得一读,特别是如果您考虑到他通过那些相对简单的实现技术实现的性能改进。

于 2013-01-21T22:53:10.860 回答
0

不,路线检查快速有效。

大多数站点几乎没有或只有一条路线。

其他站点有 30 多条路线。根据我的经验,拥有 30 条不同路线的站点在性能上没有明显的滞后。

于 2013-01-21T21:02:46.093 回答