1

在动态数据 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 看起来没有使用。

4

1 回答 1

2

你是对的,在这种情况下不会使用路线#2。路由 #2 唯一发挥作用的情况是,如果您从路由引擎请求详细信息页面 URL。因为 ListDetails.aspx 页面模板同时处理列表和详细信息视图,所以它从不请求详细信息模板 URL。

于 2008-09-27T14:29:55.637 回答