Scaffolding in an ASP.NET MVC App#

So at work I had to create a simple admin for a few new features in our app and decided I would try out a few new technologies while I was at it to not only save some time, but to see what is out there now.  My heart was set on this being a simple MVC web app, but really wanted to try ASP.NET Dynamic Data also.  Well good news is that you can use Dynamic Data in MVC fairly cleanly and easily.  By adding a simple route to the global.asax.cs file you can easily have Dynamic Data working although it is web forms based:

 MetaModel model = new MetaModel();
            model.RegisterContext(typeof(MvcApplication1.Models.NorthwindDataContext), 
                new ContextConfiguration() { ScaffoldAllTables = true });
            routes.Add(new DynamicDataRoute("DD/{table}/{action}.aspx") {
                Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
                Model = model
            });

Now this opened my eyes a little that you can easily create a hybrid web app of MVC and Web Forms.  Web Forms does have its advantages sometimes, especially when you start looking at existing tools and controls that you just need to work quickly and don't feel like reinventing the wheel.

You can download a sample project of this working in an mvc app over at codeplex. http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=14473

That same night I was playing with Dynamic Data, Rob Conery had just posted his prototype of a Subsonic MVC Add-in for Visual Studio.  I was pretty impressed with the code and views that it generated, and I think is a great start to seeing what is possible.  Both samples took less that an hour to download and implement.  I ended up spending more time integrated security across the multiple web apps on different sub-domains than getting the scaffolds to work.

Wednesday, October 29, 2008 8:10:43 AM UTC #    Comments [0]  |  Trackback

 

 

All content © 2009, Jim Zimmerman
Book
New Book
Links to me
On this page
Sponsors
Calendar
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
Archives
Tags
Blogroll OPML
Technorati
Favorite Links
Disclaimer

Powered by: newtelligence dasBlog 1.9.6264.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail