Search code examples
asp.netdynamic-data

How can I add data scaffolding to an existing ASP.NET website?


I've added in the Dynamic Data stuff to our existing website, and gotten that working as far as adding a DynamicDataManager to a page and setting a GridView to use it. However I think I'd like to get the full scaffolding functionality up and running so I don't have to write all the layouts for all the tables. Unfortunately I can't get it to work.

I've added code to Application_start() to register the data context and set up the route. I've tried with both "{table}/ListDetails.aspx" and "{table}/{action}.aspx" versions but I only get an HTTP 404 error. I also have ScaffoldAllTables set to true.

Am I missing a step or two here?

Here is my application start code:

protected void Application_Start(Object sender, EventArgs e)
        {


            RegisterRoutes(RouteTable.Routes);

        }


public static void RegisterRoutes(RouteCollection routes)
        {
            MetaModel model = new MetaModel();


            model.RegisterContext(typeof(ESLinqDataContext), new ContextConfiguration() { ScaffoldAllTables = true });


            routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
            {
                Action = PageAction.List,
                ViewName = "ListDetails",
                Model = model
            });

            routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
            {
                Action = PageAction.Details,
                ViewName = "ListDetails",
                Model = model
            });
        }

Solution

  • I needed to add

    <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, publicKeyToken=31BF3856AD364E35" /> 
    

    to the httmodules section of my web.config.