Asp.net 如何将DynamicATA路由与Mvc路由混合使用?

Asp.net 如何将DynamicATA路由与Mvc路由混合使用?,asp.net,asp.net-mvc,dynamic-data,Asp.net,Asp.net Mvc,Dynamic Data,我正在尝试创建一个区域来运行dynamicata,并将脚手架作为管理部分。这可能是工作,因为它应该,但我不能得到的路线工作 在my global.asax中,我具有以下功能来注册路由: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRo

我正在尝试创建一个区域来运行dynamicata,并将脚手架作为管理部分。这可能是工作,因为它应该,但我不能得到的路线工作

在my global.asax中,我具有以下功能来注册路由:

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("favicon.ico");
            routes.IgnoreRoute("public/{*pathInfo}");
            routes.IgnoreRoute("{resource}.js"); 
            routes.IgnoreRoute("{resource}.css"); 

            routes.MapRoute("OrderComment", "Order/{id}/comments",
                new { controller = "Order", action = "Comments", id = 0 }, // Parameter defaults
                new { controller = new NotEqual("Register", "Product", "Admin") });

            routes.MapRoute("Account", "Account/Edit/{accountId}",
                            new { controller = "Account", action = "Edit", accountId = 0 }, // Parameter defaults
                            new { controller = new NotEqual("Register", "Product", "Admin") });


            routes.MapRoute("Default", // Route name
                            "{controller}/{action}/{id}", // URL with parameters
                            new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
                            new { controller = new NotEqual("Register", "Product", "Admin") });


            if (HostingEnvironment.IsHosted) {
                routes.Add(new ServiceRoute("Register", new WebServiceHostFactory(), typeof(RegisterService)));
                routes.Add(new ServiceRoute("Product", new WebServiceHostFactory(), typeof(ProductService)));
            }
        }
在我的区域中,我将所有DynamicATA细节如下所示:

公共类AdminAreaRegistration:AreaRegistration {

}

不幸的是,到目前为止发生在我身上的“最好”的事情是,当我检查默认表时,我得到一条关于(MetaModel.VisibleTables)的消息

Message=“值不能为空。” 空。\r\n参数名称:主体“

使用以下堆栈跟踪:

   at System.Web.DynamicData.ModelProviders.TableProvider.CanRead(IPrincipal principal)
   at System.Web.DynamicData.MetaTable.CanRead(IPrincipal principal)
   at System.Web.DynamicData.MetaModel.IsTableVisible(MetaTable table)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at System.Web.DynamicData.MetaModel.get_VisibleTables()
位于System.Web.DynamicData.ModelProviders.TableProvider.CanRead(IPrincipal主体)
位于System.Web.DynamicData.MetaTable.CanRead(IPrincipal principal)
位于System.Web.dynamicata.MetaModel.IsTableVisible(元表)
位于System.Linq.Enumerable.WhereEnumerableInterator`1.MoveNext()
在System.Linq.Buffer`1..ctor处(IEnumerable`1源)
在System.Linq.OrderedEnumerable`1.d_u0.MoveNext()中
位于System.Collections.Generic.List`1..ctor(IEnumerable`1集合)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
在System.Web.dynamicATA.MetaModel.get\u VisibleTables()上
问题是我不知道为什么会这样。是路线问题还是其他问题?这可能是某种安全问题,还是我不能将动态数据放在一个区域内

dynamicata文件夹本身位于应用程序的根目录中,因为这是它使用的约定,我不打算覆盖它


编辑:我找到了一篇文章,但它似乎对我没有任何帮助。

解决我的问题的方法是在管理区域注册中创建一个页面路由,指向以下内容:

context.Routes.MapPageRoute("Admin", 
                            "admin/{pagename}", 
                            "~/Areas/Admin/Default.aspx", 
                            true);

我也有类似的问题。我喜欢动态数据如何自动为您创建数据驱动的表单,但我也喜欢MVC应用程序的简洁设计。我最终决定从我的项目中删除动态数据,让MVC使用动态MVC生成页面

context.Routes.MapPageRoute("Admin", 
                            "admin/{pagename}", 
                            "~/Areas/Admin/Default.aspx", 
                            true);