use*_*812 4 asp.net-mvc asp.net-mvc-routing asp.net-mvc-4
除了所有定义的 api 路由之外,我还想在 LegacyUriRedirect 操作中处理任何其他 url。
我试图将 routeTemplate 留空,但它只捕获根 url 并忽略任何带有段的 url。
如何更改以下代码以捕获所有包含任何段的 url?
config.Routes.MapHttpRoute(
name: "LegacyUriRedirect",
routeTemplate: "",
defaults: new { controller = "URI", action = "LegacyUriRedirect" }
);
Run Code Online (Sandbox Code Playgroud)
config.Routes.MapHttpRoute(
name: "LegacyUriRedirect",
routeTemplate: "{*catchall}",
defaults: new { controller = "URI", action = "LegacyUriRedirect" }
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1426 次 |
| 最近记录: |