在动态数据 Web 应用程序的默认 Visual Studio 模板中,Global.asax 包含以下两个示例路由。
// route #1
routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
Action = PageAction.List,
ViewName = "ListDetails",
Model = model
});
// route #2
routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
Action = PageAction.Details,
ViewName = "ListDetails",
Model = model
});
它们仅在 Action 属性上有所不同。Global.asax 中的注释表明这两个路由用于配置处理所有 CRUD 行为的单个页面。
为什么路线#2是必要的?它有什么作用吗?ListDetails.aspx 不查看路由的 Action 属性。当我注释掉路线 #2 并且我在 Global.asax 中只有路线 #1 时,似乎一切都运行良好。Route #2 看起来没有使用。