Changing the virtual folder where ASP.NET Dynamic Data templates are stored

Posted: (EET/GMT+2)

 

If you are building web applications with Visual Studio and ASP.NET Dynamic Data, you know that the default location for the page and field templates and content images is a virtual folder named "/DynamicData". This is good for simple web sites, but if you want to integrate your Dynamic Data application into an existing ASP.NET web application, you need to change this location.

As you might guess, you cannot simple rename this folder as this wouldn't work. Instead, you have to set a property called DynamicDataFolderVirtualPath in Global.asax code-behind file, and then rename your folder. This property is part of the MetaModel object that is automatically created for you in the RegisterRoutes method, which is part of the template code. Here's an example:

MetaModel model = new MetaModel();
model.RegisterContext(...);
model.DynamicDataFolderVirtualPath =
  "~/MyFolderName/DynamicData";

MSDN also features a howto article about this.