ASP.Net MVC 路由可以考虑“OR”吗?选项?
我现在有这个路由设置,
routes.MapRoute(
"OldPages", // Route name
"page{id}.html", // URL with parameters
new { controller = "WebPage", action = "Details", pageName = "oldpage", moreInfoID = 0 },
new { action = "Details" }
);
我正在从旧站点移动到新的动态站点,并捕获此路由中的所有旧 URL 以执行 301 重定向。我的旧网站的页面均以 pageX.html 或 pageXX.html 开头,其中 X 是数字。
我的路线目前可以很好地处理这个问题,但我刚刚意识到我的旧网站也有一个名为index.html的页面,所以我想知道是否可以修改该路线来处理这个问题,或者我是否必须为此创建一个新路线?
谢谢
I have this routing setup at the moment
routes.MapRoute(
"OldPages", // Route name
"page{id}.html", // URL with parameters
new { controller = "WebPage", action = "Details", pageName = "oldpage", moreInfoID = 0 },
new { action = "Details" }
);
I am moving from an old site to my new dynamic site and trapping all old URL's in this route to do a 301 redirect. My old site's pages all start with pageX.html or pageXX.html where X is a number.
My route currently handles this fine but I have just realised that my old site also has a page called index.html so I was wondering if the route can be modified to handle that or will I have to create a new route for just that?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为一次性的,我会添加一条额外的路线。如果您反复遇到这种情况,您可以使用正则表达式路由处理程序或自定义路由处理程序,但这些都是重量级技术,对于单一情况来说就太过分了。
For a one-off, I would add an extra route. If it's something you encounter repeatedly you could use a regular expression route handler or a custom route handler, but those are heavyweight techniques which would be overkill for just a single case.