altnetconf – Scott Guthrie announces ASP.NET MVC framework at Alt.Net Conf

asp.net mvc framework 

Note:  Much more MVC information coming.  Subscribe to my feed: http://feeds.feedburner.com/jeffreypalermo Subscribe to email feed.

Scott Guthrie proposed a topic at the Alt.Net Conference today, and the topic was an overview of the MVC Framework his team is working on.  His topic is actually the first timeslot of the conference at 9:30am tomorrow morning.  Just about everyone showed interest, so I wouldn’t be surprised to see most of the folks just listening.

Scott and I had supper after the opening, and I received a personal demo of the prototype.  First, here are some of the goals:

  • Natively support TDD model for controllers.
  • Provide ASPX (without viewstate or postbacks) as a view engine
  • Provide a hook for other view engines from MonoRail, etc.
  • Support IoC containers for controller creation and DI on the controllers
  • Provide complete control over URLs and navigation
  • Be pluggable throughout
  • Separation of concerns
  • Integrate nicely within ASP.NET
  • Support static as well as dynamic languages

I’m sure I missed some of the goals, and more people will blog their takeaways since this all is public information.

The first question might be: Is webforms going away?  Do I have to rewrite my web applications?  Some people might wish, but no.  Both models will be supported and even be supported within the same web application.  I, for one, after seeing this, think it is very good, and my company will be recommending it to our clients.

We might get a public CTP by the end of the year, and it will be released in a similar fashion as ASP.NET AJAX was, as an add-on after the Visual Studio 2008 release some time next year.

URLs

The default URL scheme will look something like this:

/<RouteName>/<Action>/<Param1>/<Param2>

where RouteName is configured to map to SomeController.  Multiple routes can map to the same controller for the purpose of providing more URLs (think SEO).

The developer can completely override the URL processing also by providing an implementation of an interface. 

Controllers

Controllers will inherit from a base class by default, but it doesn’t hinder unit testing, and it’s not even required.  I’ll probably use the option of implementing the IController interface instead and creating a controller factory to support controller creation using my IoC container of choice (currently StructureMap).  In this manner, I implement an interface with one method that accepts IHttpContext (yep, we have an interface now), and RouteData, a simple DTO that includes the action and parameters for the web request (parsed from the URL scheme you are using).

Views

Like I said before, NVelocity, Brail, etc can be bolted on as view engines, and ASPX is provided as a view engine (the only thing that has been changed is that the code-behind will inherit from ViewPage as opposed to the current Page).  Controllers can either using IViewEngine (I think that’s the name) to request a view by name (key) or using a helper method on the optional controller base class RenderView(string, viewData).  The default model uses a DTO for the objects passed to the view, so it is similar to MonoRail’s property bag except it’s a strongly-typed DTO (using generics for that), so when you rename stuff with Resharper, you don’t have to worry about any string literals lying around.

My impressions

I first saw the early prototype in March of this year, and I was encouraged.  I was able to give some early feedback, which has already been encorporated into the product.  I’m not one to promote a Microsoft offering just because it’s there (I have never recommended the use of MSTest over NUnit, for instance), but I will say this: As soon as I can get my hands on a build, I will be building something with it.  I am very encouraged by this, and I think they are going in the right direction.  While they have chosen a model to use with demos, they have broken down the walls.  Interfaces abound, and none of it is sealed.  I will start by swapping out the controller factory so I can get my IoC container in the mix, but it’s easy to do.  For testing, there is no coupling of the controller.  The views are decoupled.  The httpcontext is decoupled with the new IHttpContext interface.  The actions are simple public methods with an attribute attached to them ([ControllerAction], I think).

Isn’t it just like MonoRail?

Someone using MonoRail for more serious project than me can comment more intelligently, but here goes.  MonoRail is MVC.  This is MVC, so yes, it’s very similar but different.  This gives us a controller that executes before a view ever comes into play, and it simplifies ASPX as a view engine by getting rid of viewstate and server-side postbacks with the event lifecycle.  That’s about it.  MonoRail is much more.  MonoRail has tight integration with Windsor, ActiveRecord and several view engines.  MonoRail is more than just the MVC part.  I wouldn’t be surprised if MonoRail were refactored to take advantage of the ASP.NET MVC HttpHandler just as a means to reduce the codebase a bit.  I think it would be a very easy move, and it would probably encourage MonoRail adoption (even beyond its current popularity).

 

[tags:  altnetconf, asp.net mvc] 

This entry was posted in altnetconf, Featured. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

26 Responses to altnetconf – Scott Guthrie announces ASP.NET MVC framework at Alt.Net Conf

  1. Codeville says:

    I’m really glad we’re finally moving away from the clumsy WebForms model and getting some much-needed streamlining.

    If you’re getting into MVC, you might like to try out an open-source *client-side* MVC library for ASP.NET that makes it really easy in many circumstances to build highly dynamic UIs without AJAX or postbacks. There are demos linked from my blog
    http://blog.codeville.net/2007/10/18/jmvcnet-neat-client-side-mvc-for-aspnet/

  2. Hadi Hariri says:

    All these actions remind me of how we used to develop web applications around 6 years ago in the days of ISAPI. With Delphi we had this technology called WebBroker which was based on actions and parameter parsing. Loved it then, love it now.

  3. Sanjay Talon says:

    ScottGu and ScottHa are impressive

  4. @Blake,
    I plan on posting a way to ease into this, so stay tuned!!

  5. Jeff, certainly the new MVC framework is exciting and seems to have a ton of promise. Is it possible to do something similar using ASP.Net today? How do you typically write ASP.Net MVC-ish apps in the WebForm world right now that are capable of can handling the various complex UI scenarios that we commonly face today? Have any code samples or maybe a reference implementation to discuss?

    Thanks!

    /bc

  6. Yuriy says:

    Will server control relying on postbacks work in this environment? I have some nice controls using syncpostback for their internal purposes.

  7. sergiopereira says:

    @Adam,
    The source code will be available just like the announced source code availability for the greater part of the .Net framework. I.e. you’ll be able to browse and step into it but not recompile and distribute.

  8. Dang it all, I was going to be there, but stayed behind to do an MSDN launch…

    Anyway, did Mr. Guthrie say anything about a release date/timeframe?

  9. Is ASP.NET MVC going to give us source code, a la EntLib, or just black-box compiled .DLLs, a la most of the .NET framework? At least it’s not tied to Visual Studio versions, so that’s a plus.

    Without source, does this library tie us all into the standard Microsoft long-update-cycle for bug fixes?

  10. SixYo says:

    Good stuff ~~~

  11. Alex says:

    Thanks for posting this information. I cannot tell you how excited I am hear about this. I enjoy using MR and try to emulate its simplicity in my own apps, but I am hesitant to use it in our production application since we have a dependency on third party tools. Since MS will be developing an MVC framework, my guess is that I will be able to use my third party tools with it, and that will be great news.

  12. @Ricardo,
    No it won’t. WCSF serves a different purpose than the MVC framework

  13. Ricardo Fiel says:

    Will this make the Web Client Software Factory (http://www.codeplex.com/websf) obsolete?

  14. Steve says:

    Finally.

    Good stuff. Glad to see the asp.net team take this positive course of action.

    I can only hope I can use my IoC of choice, in addition, I hope the viewengine is done well.

    Monorail has ‘ViewComponent’s – what will the ms mvp solution provide as far as ‘controls’ go?

  15. Colin Ramsay says:

    I think this comment:

    “MonoRail has tight integration with Windsor, ActiveRecord and several view engines.”

    Is maybe a little ambiguous. While Monorail CAN integrate will several view engines, AR and Windsor, out of the box there is absolutely no dependancy or real default integration.

    I know this is probably what you meant but I didn’t think it was 100% clear :>

  16. Thomas Eyde says:

    I really hope this runs on ASP.NET 2.0.

  17. sober mind says:

    Silverlight, ExpressionBlend, .Net 3.0, as well as, the plethora of other inconsequential toys that have poured out of Redmond over the past two years, will soon end up on the dump site of history.

    An “MVC Framework,” as you call it, is the biggest news coming from the Scott Guthrie fiefdom, in the past two years.

  18. Sam Smoot says:

    @Jeffrey, no, believe me, I’ve said the same to others. That’s not the point, but it’s probably off topic anyways. Sorry.

  19. @Sam,
    I am in the OSS community, and there is a lot of adoption. If you compare to the world, then no, but I’m not worried about that. I, too, have released an open source project that folks didn’t pick up and run with, but that’s no big deal either. Other folks aren’t obligated to use my software, just like no one is obligated to buy a product from any company.

  20. @Simone,
    You explicitly do NOT have to derive from a base class. The minimum required is to implement the IController interface.

  21. ASP.NET MVC Framework at ALT.NET Conf

  22. ASP.NET MVC Framework at ALT.NET Conf

  23. Sam Smoot says:

    Jeremy, I don’t understand a couple of your comments at the end there. You said “gives us a controller…before a view ever comes into play”. Could you elaborate on what you meant? It’s been a _long_ time since I looked at Monorail, but is that not how it works there?

    One other minor point… it’s… sad I guess, how little community participation in OSS there is in .NET land. I put out a ASP-ish templating library in *January*, mentioned it several times, and never a spark of interest in it from the .NET community. It’s not that people aren’t asking for almost exactly this, but they seem to have zero motivation to pick up the ball and run with it. Here’s a google-cache of the post I’m talking about (I don’t bother maintaining my blog these days ;) ): http://64.233.167.104/search?q=cache:BaLAzvi6n_kJ:substantiality.net/archives/2007/1/29/templatenet_part_ii_the_son/+template.net+substantiality&hl=en&ct=clnk&cd=1&gl=us&client=safari

    This probably sounds like sour-grapes. Believe me, it’s not. If someone else bothered to come out with a similar lib I wouldn’t loose any sleep over it. I’m certainly not interested in maintaining it. It’s just sad how little community participation there seems to be. If Hamilton doesn’t serve it up wrapped with a big red bow on a fantastic website, or MS doesn’t deliver it themselves, the community is willing to limp along as long as it takes for someone else to drop it into their lap. And even when that happens, the .NET community has to be actively sold on the idea. As if the .NET community is doing the OSS contributor a favor by using their code.

    That went on longer than I intended. I guess it’s just how I roll. :-D Anyways, I think that may be the first time I thought of it that way… disappointing.

  24. Simone says:

    The fact that controllers have to inherit from a base class (presumably from ASP.NET) make me think that this cannot be used as framework agnostic controller, but only related to ASP.NET (not winform or wpf).
    Hope this thing doesn’t come out as Linq/Entity Framework

  25. Dan says:

    Sounds great, in fact is what I’m doing nowadays.
    A front controller ( equivalent to the asp.net MVC handler, where I map the URL to the controller ), the controllers and a view engine.
    I’m using a view engine from MonoRail but decoupled of the Castle framework.

    I suppose server controls can’t be used with the MVC ASPX view engine, right ??

    And I don’t understand why to release CTPs an so on, to me seems dead simple…

Leave a Reply