默认动态数据模板中是否需要 PageAction.Details 路由?
在动态数据 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 条路线时,似乎一切都运行良好。 2 号路线看起来没有被使用。
In the default Visual Studio template for a dynamic data web application, Global.asax includes the following two sample routes.
// 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
});
They only differ by the Action property. The comments in Global.asax indicate the two routes are used to configure a single page that handles all CRUD behaviors.
Why is route #2 is necessary? Does it do anything? ListDetails.aspx does not look at the Action property of the route. It seems that everything runs fine when I comment out route #2 and I only have route #1 in Global.asax. Route #2 looks like its not used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的,在这种情况下不会使用路线 #2。 路由 #2 唯一发挥作用的时候是当您从路由引擎请求详细信息页面 URL 时。 由于 ListDetails.aspx 页面模板同时处理列表视图和详细信息视图,因此它从不请求详细信息模板 URL。
You're right, route #2 isn't going to be used in this instance. The only time route #2 would come into play is if you were requesting a details page URL from the route engine. Because the ListDetails.aspx page template handles both the list and details views, it never requests a details template URL.