Notes on ASP.NET MVC CodePlex Preview 4

(If you want to skip all the blah blah blah, go straight to the release)

What I love about working with The Gu (aka ScottGu, the man with many aliases) is that he makes my life easier with his gargantuan and detailed blog posts covering the features of each release. This allows me to follow up and fill in some details with a much shorter post, as by the time we get a release out the door, I’m usually too exhausted to write such a detailed post as he does. Yeah, excuses excuses.

In his latest post, Scott covers the ASP.NET MVC CodePlex Preview 4 release in two parts. This is the next in a continuing series of preview releases that alternate between full CTP level releases on ASP.NET and interim releases on CodePlex. Unlike previous CodePlex releases, this one contains an MSI installer for convenience. There are still some rough spots with some of the new features as we tried to get a lot into this release to elicit feedback. In fact, I’ve been doing some app building today and have already run into some areas for improvements with the Ajax helpers. I look forward to hearing your feedback as well.

MVC Futures

One thing you’ll notice in the project template that Scott didn’t cover in much detail is that we include a new assembly, Microsoft.Web.Mvc.dll. The release notes explain what this is.

The ASP.NET MVC team builds prototypes for a lot of features during the course of normal development. Some of these features will not be included in the RTM release, but are very likely to be included in a future full release. We’ve moved many of these features into a separate assembly, Microsoft.Web.Mvc.dll.

This follows what the ASP.NET’s team intends the term Futures to mean when it comes to products. Futures should contain features that we think has a decent chance of making it into the framework. If we implement something we are pretty sure we have no intention of including in the framework, we’ll typically post it as a blog sample or something to that effect.

Component Controller

For those that have used this, you’ll notice that we removed the ComponentController class. Instead, we renamed RenderComponent to be RenderAction and re-implemented it so that it works against a normal controller. This code is was moved to the MVC Futures assembly since we’re not planning to include it in the RTM.

My personal opinion is that this violates the separation of concerns so important to the MVC pattern. Having a method within your view calling back into a controller in order to render out a bit more view makes me feel a wee bit dirty ;). We’re developing prototypes for an alternative approach. In the meanwhile, I recognize that for a small sacrifice of pattern purity, this method is very useful, hence its inclusion in the MVC Futures assembly, but do understand that you use it at your own risk.

What’s Next?

The roadmap for ASP.NET MVC has been up on the CodePlex site for a while. We still have more cleanup and implementation work to do on the Ajax features, as well as existing and new helper methods. Likewise, we are tackling the problem of how should you report validation errors to the user via a common error reporting mechanism. This might not handle validation itself, but gives everyone a common place to put validation messages and allows for some of HTML helpers to be aware of these messages and render themselves accordingly.

And before I forget, you can download ASP.NET MVC CodePlex Preview 4 from the release page.

Technorati Tags:

What others have said

Requesting Gravatar... Shane Milton Jul 16, 2008 6:01 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
I know what one of my weekend projects are going to be now! :)
Requesting Gravatar... Simone Jul 16, 2008 6:14 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
That's the first time I get the announcement and I'm not on holiday... I missed 4 announcement before :)
Requesting Gravatar... Lamin Barrow Jul 16, 2008 7:44 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Yeppeeee preview 4 is out finally. I can't wait to checkout all the new stuff. Thanks for all your effort Phil.
Requesting Gravatar... Shiju Varghese Jul 16, 2008 8:51 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Great work. Congrats to the MVC team.
Requesting Gravatar... Adam Webber Jul 16, 2008 12:21 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Hi,

I'm looking forward to learning about your alternative approaches to the 'dirty' RenderComponent technique. There is certainly a need to incorporate a mechanism to separate out chunks of V-C so that composable pages do not end up with a mega controller.

Note also that moving this to Futures contradicts your earlier statement that 'If we implement something we are pretty sure we have no intention of including in the framework, we’ll typically post it as a blog sample or something to that effect.' (as opposed to putting it in Futures)

Best wishes,

Adam.
Requesting Gravatar... Fredrik Jul 16, 2008 1:47 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Hi,

I am dying to work with Asp.Net MVC and IronRuby.

I don't know when that day will come. I dont hear any news about it. My last hope was preview 4, but too failed.

How long should i continue working with Rails only.

Hello Phil...Please hack some news from asp.net team/DLR team and share it here.

Thanks
Requesting Gravatar... Jay Patel Jul 16, 2008 4:46 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Its superb man . . . We were expecting it soon . . .
Requesting Gravatar... Torkel Jul 16, 2008 4:48 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Hi,

Just a question regarding the Ajax helpers, how tied are these to a specific javascript library? If it is possible, without restricting featuers to the lowest common denominator to much, it would be great if the ajax library was pluggable, so you could for example use JQuery or Prototype with the MVC Ajax helpers.
Requesting Gravatar... thr Jul 16, 2008 5:25 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Has anybody tried to use RouteDebuger with preview4?
Requesting Gravatar... Steve Jul 16, 2008 10:19 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Could more details be given on exactly what is in 'Futures' ?
Requesting Gravatar... Steve Jul 16, 2008 10:27 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
I'm missing html helpers now?

ie. submitbutton, image, etc...

Were these removed?
Requesting Gravatar... Steve Jul 16, 2008 10:35 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
ok, they are now in Futures?

Why???

Seems odd to move core items like SubmitButton and Image to Futures

It was there in Preview 3, works fine - I don't get the change? Please explain this???
Requesting Gravatar... Steve Jul 16, 2008 10:49 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Sorry, seems that after I rebuilt again, closed the page, and reopened those are now there.

Wierd.

I did add a reference in my web.config to the futures - then saw the extensions - would this be correct?

I would think some of those items would no longer be futures.
Requesting Gravatar... Steve Jul 16, 2008 10:58 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Another question:

Now I'm getting this error:

"The provider requires SessionState to be enabled"

Is there something new here ???
Requesting Gravatar... Jamie Jul 16, 2008 11:11 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Is there any chance you guys will ramp up efforts on sub-controllers and try to get them into the official release? All of this AJAX stuff is nice, but kind of unnecessary. Most of the AJAX libraries out there do just great on their own and it would be easy as pie to write our own helpers.

Sub-controller support on the other hand is something that seems sorely lacking in the current MVC framework and have the most chance of causing a lot of pain to rework things when it is finally released. If we start using RenderComponent now, then something totally different is released later, that's much more of a change than just reworking a few helpers for AJAX. I know that AJAX is one of the silver hammers everyone's all hyped about right now, but why is it superceding good componet support?

At the very least, maybe we could get more visibility into what you're doing with sub-controllers so if we roll our own in the meantime we won't have as much to change later?
Requesting Gravatar... varun Jul 17, 2008 1:07 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
[yeahh!!!] finally !!!!
Now after a long wait I can use some normal Loging in and login out stuff without jumpin into any mess!!! [u]and the Ajax support is deeply appreciated[u] thanx
Requesting Gravatar... Gavin Jul 17, 2008 2:14 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
If anyone else has issues with that "sessionstate required" problem, see the post on the mvc forums at:

forums.asp.net/p/1291611/2496928.aspx#2496928
Requesting Gravatar... Emad Ibrahim Jul 17, 2008 3:37 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Very cool. I can't wait to upgrade yonkly.com

I love the new tempdata implementation which should make testing a lot easier.

I am a little nervous of the integration with microsoft ajax because I use jquery... hopefully things will work out.

I love MVC and don't want to do web forms ever again :)

Keep up the great work
Requesting Gravatar... Rob G Jul 17, 2008 4:16 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Hey Phil, great stuff! Any views (no pun intended) on the best way to go from P3 to P4? Doesn't look like the MSI likes the fact that we've got P3 installed - any easy way to move all the test sites I've created with P3 to P4?

If not - oh well, time to roll up those sleeves!

cheers,
Rob G
Requesting Gravatar... haacked Jul 17, 2008 4:27 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
@Ryan we're definitely looking into it, and have been working on such features in parallel to all the work we released in Preview 4. Do you have certain specific scenarios that are blocked or made difficult you'd like to supported?
Requesting Gravatar... haacked Jul 17, 2008 4:29 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
@Rob you have to uninstall P3 first. However, updating an existing site should be pretty easy. Check out the readme notes.
Requesting Gravatar... Mike Jul 17, 2008 4:38 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
"For those that have used this, you’ll notice that we removed the ComponentController class. Instead, we renamed RenderComponent to be RenderAction and re-implemented it so that it works against a normal controller. This code is was moved to the MVC Futures assembly since we’re not planning to include it in the RTM."

Can you explain this further and also explain the alternative, because I thought this was exactly what was needed and don't understand why it's bad.
Requesting Gravatar... Mike Jul 17, 2008 4:44 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Could you guys release a zip with just the dll's, I don't really like 'installers'
Requesting Gravatar... david alpert Jul 17, 2008 6:14 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
How does Html.RenderUserControl(...) fit into the refactoring of RenderComponent into RenderAction?

I wasn't using RenderComponent, i was using RenderUserControl, but that was looking for a Component Controller in the /Components/ folder....

Now my "ComponentController" inherits from "Controller" in the absence of ComponentController, so i moved it into my /Controllers/ folder, but now RenderUserControl(...) can't find it!

All this to enable paging as a user control!
Requesting Gravatar... david alpert Jul 17, 2008 6:32 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
oops. measure twice, cut once, or something like that.

I was looking at the wrong place in my code; RenderUserControl still works like a dream.
Requesting Gravatar... tgmdbm Jul 17, 2008 11:22 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Hey Phil, I thought that the RenderAction method was the best way to encapsulate some reusable logic... that is until it came time to test it. You really see how badly it breaks the MVC model.

ComponentController was fine but you lost your IoC goodness.

Looking forward to how this looks in the next preview.
Requesting Gravatar... Meisinger Jul 17, 2008 11:38 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Could you image what WebForms would be like if a similar approach was taken like this one for MVC?

I love getting the bits and getting to play around with them early. I also appreciate the fact that your team is so open to suggestions and feedback. It has really been great to see some of our feedback getting put in and considered.

I think that we all realize some hard decisions are going to have to be made for RTM (what's in, what's out, what goes to Futures, etc...) but I think that we have a real good opportunity with leveraging the MvcContrib project. With the bits made available to us there is nothing stopping us from writing our own jQuery "providers" etc...

In short... keep up the great work
Requesting Gravatar... David O'Hara Jul 18, 2008 12:18 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Phil, I was curious about the decision to add the Eval method to the Controller and pull it's use in the indexer. Could you speak to that decision or point me to someone who could?? Thanks!!
Requesting Gravatar... Joel Duvall Jul 18, 2008 12:57 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Phil, I love the new MVC framework.

For Validation it would be nice if you could keep existing the existing technique used in Dynamic Data by having a metadata class or being able to use the metadata class if available. I think I saw or heard you guys were already thinking this way. I would love to see what this might look like as soon as possible.

Thanks!
Requesting Gravatar... Andrew Jul 18, 2008 8:00 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
I can not comprehend the decision regarding Component Controller, the team took something that was working reasonably well and completely bodged it up so much so its now considered bad usage (and awkward to use) and wont be in RTM.

I have been using them successfully and am now stuck at needing output caching and having to re-engineer these components to use this broken method.
Requesting Gravatar... Corey Gaudin Jul 18, 2008 11:27 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
Comment to tgmdbm.

I here what you said about RenderAction, however, keep in mind that it does not really break down in testability wise, because you should be testing all of your controller and actions. So if a particular view calls a RenderAction(c => c.ControlPiece(someKey)), then you should be writing a test for the original action and the ControlPiece action.

So while I agree the controller doesnt flow up the model data for all of the view, the controller is still the keeper for getting the model data. Its no different then using Javascript to use AJAX to partially pull html or a json object (and build html) once a view is loaded. The only difference is it is done before the page is fully rendered to the client.

Baring this, I see no reason why it violates a MVC pattern. The controller is still keeping the model data logic behind it, its just that you might have a call to an action more than once per view. Again, no different that a AJAX heavy view which handles parital rendering.
Requesting Gravatar... Serge Van Meerbeeck Jul 18, 2008 7:17 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
I really like the momentum of ASP.NET MVC.

However, I was wondering: I just migrated to Preview 4, and I seem to miss a couple of extension methods on the HtmlHelper for Button, more specifically the ones that take an Expression> as an argument. No harm done, it takes 2 minutes to add them myself, but nevertheless ...

Any reason why they were removed while moving the extensions to the Futures dll?
Requesting Gravatar... Ahtesham Jul 18, 2008 7:59 PM
# re: Notes on ASP.NET MVC CodePlex Preview 4
haacked , what about helper of views in this preview , also what about subcontrollers , also one more thing why not any one who understand MVC well has put a extensive example on the net , so ppl like me who are not that advanced can learn how they can do stuff in MVC, why mostly exmple on net is one or 2 views.hope You Gods of MVC will answer that
But Great learning Curve for New ppl like me ,Thanks
Ahtesham
Requesting Gravatar... Mehrdad Aug 06, 2008 6:16 AM
# re: Notes on ASP.NET MVC CodePlex Preview 4
I think an important part in MVC pattern implementation is the routing part. This is usually best to be done declaratively. Some MVC focused frameworks such as Cocoa has done this well (while I don't like Apple's interface builder system, I think the routing part is done pretty well). I think MVC needs some XML based declartive syntax to declare connections (probably using a special build provider or something you know better ;) )

What do you have to say?

(will show your gravatar)
Please add 1 and 7 and type the answer here: