我的 MVC asp.net 动态数据 Web 应用程序中的脚手架问题
我正在开发一个 asp.net MVC 应用程序。我的 global.asax 文件中有以下代码用于动态数据实现
代码片段 1:
model.RegisterContext(typeof(MyCustomEntities), new ContextConfiguration() { ScaffoldAllTables = false });
代码片段 2:
routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
{
Constraints = new RouteValueDictionary(
new { action = "List|Details|Edit|Insert" }),
Model = model
});
代码片段 3:
//routes.Add("MyTable1", new DynamicDataRoute("MyTable1/{action}.aspx")
//{
// Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
// Model = model,
// Table = "MyTable1"
//});
代码片段 4:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.MapRoute(
"Default",
// Route name
"{controller}/{action}/{id}",
// URL with parameters
new { controller = "Home", action = "Index", id = "" }
// Parameter defaults
);
问题是尽管有scaffoldingAlltables = false,但我还是得到了默认值中所有表的列表.aspx 页面。
我有大约 50 个表,但我只需要 3 或 4 个表的动态数据。如果我注释代码片段 4,问题就会解决,但我不能这样做。有解决方法吗?
我还尝试注释代码片段 2 并为我想要列出的所有表添加代码片段 3。它仍然显示所有 50 张桌子。
问候,
哈里
I am working on an asp.net MVC application. I have the following code in my global.asax file for dynamic data implementation
Code snippet 1:
model.RegisterContext(typeof(MyCustomEntities), new ContextConfiguration() { ScaffoldAllTables = false });
Code snippet 2:
routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
{
Constraints = new RouteValueDictionary(
new { action = "List|Details|Edit|Insert" }),
Model = model
});
Code snippet 3:
//routes.Add("MyTable1", new DynamicDataRoute("MyTable1/{action}.aspx")
//{
// Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
// Model = model,
// Table = "MyTable1"
//});
Code snippet 4:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.MapRoute(
"Default",
// Route name
"{controller}/{action}/{id}",
// URL with parameters
new { controller = "Home", action = "Index", id = "" }
// Parameter defaults
);
Problem is despite of having scaffoldingAlltables = false, I get the listing of all tables in my Default.aspx page.
I have aroung 50 tables but i want dynamic data for only 3 or 4 tables. The problem gets solved if I comment code snippet 4, but I cannot do that. Is there a workaround for this?
I also tried commenting code snippet 2 and adding code snippet 3 for all the tables I want to list. Still it shows all the 50 tables.
Regards,
HARI
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论