ASP.NET MVC 2 Preview 2

Today we just released ASP.NET MVC 2 Preview 2 for Visual Studio 2008 SP1 (and ASP.NET 3.5 SP1), which builds on top of the work we did in Preview 1 released two months ago.

Some of the cool new features we’ve added to Preview 2 include:

  • Client-Side Validation – ASP.NET MVC 2 includes the jQuery validation library to provide client-side validation based on the model’s validation metadata. It is possible to hook in alternative client-side validation libraries by writing an adapter which adapts the client library to the JSON metadata in a manner similar to the xVal validation framework.
  • Areas – Preview 2 includes in-the-box support for single project areas for developers who wish to organize their application without requiring multiple projects. Registration of areas has also been streamlined.
  • Model Validation Providers - allow hooking in alternative validation logic to provide validation when model binding. The default validation providers uses Data Annotations.
  • Metadata Providers - allow hooking in alternative sources of metadata for model objects. The default metadata provider uses Data Annotations.

Based on this list, you’ll notice a theme where in Preview 1, we tied much functionality directly to Data Annotation attributes, in Preview 2 we inserted abstractions around our usage of Data Annotations which allow hooking in custom implementations of validation and metadata providers.

This will allow you to do things like swapping out our default validation with the Enterprise Library Validation Block for example. It also allows providing implementations where model metadata is stored in alternative locations rather than via attributes, with a bit of work.

What About Visual Studio 2010?

The tools for this particular release only work in Visual Studio 2008 SP1. The version of ASP.NET MVC 2 Preview 2 for Visual Studio 2010 will be released in-the-box with Visual Studio 2010 Beta 2. You won’t need to go anywhere else, it’ll just be there waiting for you. Likewise, the RTM of ASP.NET MVC 2 will be included with the RTM of Visual Studio 2010.

Therefore, if you want to try out the new HTML encoding code blocks with ASP.NET MVC 2 Preview 2, you’ll have to wait till Visual Studio 2010 Beta 2 is released. But for now, you can try out Preview 2 on VS 2008 and start providing feedback.

What others have said

Requesting Gravatar... James Curran Oct 01, 2009 3:34 AM
# re: ASP.NET MVC 2 Preview 2
That's so cool that you've included jQuery validation.
Requesting Gravatar... Martin MacPherson Oct 01, 2009 3:58 AM
# re: ASP.NET MVC 2 Preview 2
Speaking of VS 2010 Beta 2, any ideas when it is set to be released?
(I gotta ask ;)
Requesting Gravatar... Fujiy, Felipe Oct 01, 2009 4:08 AM
# re: ASP.NET MVC 2 Preview 2
jQuery client side validation will be helpfull.
Requesting Gravatar... Khaja Minhajuddin Oct 01, 2009 4:18 AM
# re: ASP.NET MVC 2 Preview 2
This is good news, We are currently building a site on ASP.NET MVC 1, and the development for this will probably go on for another two months. I am thinking we should use ASP.NET MVC 2 since it's already in Preview 2. Phil, What would you advice? Should we wait for the final RTM? Does Preview 2 have a go live license?
Requesting Gravatar... Kieron Lanning Oct 01, 2009 4:20 AM
# re: ASP.NET MVC 2 Preview 2
Hey, well done guys/ gals! Going to play with it tonight.

Is there reason we can't use the assemblies in VS2010 Beta 1 for those of us banging away on the MVC 2 Preview 1?
Requesting Gravatar... Bart Plasmeijer Oct 01, 2009 4:50 AM
# re: ASP.NET MVC 2 Preview 2
Quick Note: Visual Studio installed templates still uses the old name, 'A project for creating an application using ASP.NET MVC 2 Preview 1 (.NET Framework 3.5)' The generated project is preview 2.
Requesting Gravatar... Joe Oct 01, 2009 5:02 AM
# re: ASP.NET MVC 2 Preview 2
Is the final of MVC 2 going to be released before VS 2010 at all, or both together?
Requesting Gravatar... Betty Oct 01, 2009 5:06 AM
# re: ASP.NET MVC 2 Preview 2
Does MVC 2 allow for easy swapping out of the viewpage with another that uses generics? The current control parser seems to be hardcoded to use System.Web.MVC.ViewPage<> as soon as you put angle brackets in the type field.

Also wondering if you were looking at anything like subroutes, so you can setup a tree of routes which could potentially mean expensive route constraints are only run once per request (caching almost eliminates this I guess). Although since routing was moved into the core framework I guess it isn't developed by the MVC team now.
Requesting Gravatar... KevDog Oct 01, 2009 6:13 AM
# re: ASP.NET MVC 2 Preview 2
I'm nothing but impressed by the speed and flexibility that you and your team have brought to the development cycle of this product, Phil. Thanks for the work you guys are doing and for making web development fun again.
Requesting Gravatar... zihotki Oct 01, 2009 6:27 AM
# re: ASP.NET MVC 2 Preview 2
Hi,
Could you please fix a link to Release Notes? At the moment it links to http://www.asp.net/mvc/ .
Requesting Gravatar... Victor Oct 01, 2009 6:44 AM
# re: ASP.NET MVC 2 Preview 2
I would like to know more about Model Validation and Metadata providers ;)
Requesting Gravatar... Vijay Santhanam Oct 01, 2009 7:14 AM
# re: ASP.NET MVC 2 Preview 2
Whoops, I downloaded this and installed it with the mind to upgrade but several won't run because MS.MVC.Futures.dll isn't ready yet to match all the new MVCHtmlString helpers.

Also, if you're using the T4MVC.tt templates for strongly typed urls, you'll need to hack changes for that.

I'll try upgrading in a day or two.

I am eagerly awaiting client-side validation helpers.. that's gonna rock
Requesting Gravatar... Bob Oct 01, 2009 8:15 AM
# re: ASP.NET MVC 2 Preview 2
According to the Release Notes, this cannot be installed alongside MVC 1. Is that really true?
Requesting Gravatar... Piers Lawson Oct 01, 2009 8:28 AM
# re: ASP.NET MVC 2 Preview 2
Would love for you to allow validation of an entire model to populate model state. The problems I encountered I have highlighted here: A RESTful Wizard Using ASP.Net MVC 2… using Data Annotations. Something like the Validator class that is coming with .Net 4.0 but that would populate a Model State directly would be cool. Great to see you are moving this along!
Requesting Gravatar... Craig Stuntz Oct 01, 2009 10:03 AM
# re: ASP.NET MVC 2 Preview 2
Very nice. Thanks for the frequent and early shipments!
Requesting Gravatar... Matt Hidinger Oct 01, 2009 10:25 AM
# re: ASP.NET MVC 2 Preview 2
Hi Phil,

Thanks for the quick release, I've upgraded my MVC2 Preview 1 project without problems and enabled the client side validation, it's working great!

On another topic regarding HTML Helpers, does your team have any plans for offering built-in Fluent Html Helpers? I have thoroughly enjoyed the fluent HTML methods from MvcContrib and would love if these were included out of the box with MVC 2. A slight point of contention I have while trying to influence co-workers to try out MVC is always regarding the mass number of overloads and not really knowing what method param does what without invoking intellisense (i.e., is the first param of ActionLink the Link Text, the Action Name, or a Controller Name? The fluent versions make this very apparent and much nicer to use.

One other thing I absolutely love from MvcContrib is the clever lambda-based anonymous dictionaries instead of creating anonymous types.

Quick "psuedo-code" example:
html.TextBox().Style(border => "solid 1px black", width => "200px")

as opposed to:
html.TextBox().Style(new { border = "solid 1px black", width = "200px" })

Not much different really, just throwing my 2 cents in. :)

Thanks again for all the efforts!
-Matt
Requesting Gravatar... lynn Oct 01, 2009 12:13 PM
# re: ASP.NET MVC 2 Preview 2
Phil, really like the Single Project area support - that should be a big help.

I am using T4MVC to get strong typed route calling, but I was wondering if out-of-box support for this has been shelved for MVC 2?
Requesting Gravatar... Haacked Oct 01, 2009 3:04 PM
# re: ASP.NET MVC 2 Preview 2
ASP.NET MVC 2 Preview 2 is fully side-by-side with ASP.NET MVC 1.0. It's not side-by-side with ASP.NET MVC 2 Preview 1.
Requesting Gravatar... Mario Oct 01, 2009 9:52 PM
# re: ASP.NET MVC 2 Preview 2
Hi Phil,
Do you know how many previews they will be before release?
Requesting Gravatar... Dmitriy Nagirnyak Oct 01, 2009 11:37 PM
# re: ASP.NET MVC 2 Preview 2
Great work. Thanks a lot for that.

Any changes to the routing?
Will it be possible to configure links generation for (non)SSL actions?

When would it be possible to configure absolute links using ONLY routing?
Requesting Gravatar... Dario-g Oct 02, 2009 1:14 AM
# re: ASP.NET MVC 2 Preview 2
When GoLive???
Requesting Gravatar... Diego Oct 02, 2009 6:07 AM
# re: ASP.NET MVC 2 Preview 2
Uhm.... i tried to run my project developed with the preview 1 with this new release, but i got several errors caused by new MvcHtmlString result of Helpers.

It's there a way to resolve or I have to add a "ToString()" on every helper?

Thanks a lot.

Bye
Diego
Requesting Gravatar... Shaharyar Oct 02, 2009 6:42 AM
# re: ASP.NET MVC 2 Preview 2
Is there any support for automatic paging planned for the upcoming releases?
Requesting Gravatar... yemek tarifleri Oct 02, 2009 11:07 AM
# re: ASP.NET MVC 2 Preview 2
Great news.
Requesting Gravatar... Mike Oct 02, 2009 2:05 PM
# re: ASP.NET MVC 2 Preview 2
"in a manner similar to the xVal validation framework"

Reinventinging the wheel much lately?
Requesting Gravatar... Gauthier Segay Oct 03, 2009 7:18 AM
# Support for ala monorail viewcomponents
Hi, nice to see the framework maturing.

I'm wondering if there is anything supporting the viewcomponent system found in Castle MonoRail.

As some may know, they are similar to usercontrols or customcontrols but most importantly are viewengine agnostic where usercontrols / customcontrols are for WebForm viewengine only.

I'll try to look at the advances on the client side validation, I'm pretty used to (almost) automatic jquery validate plugin integration with the use of MR FormHelper and expecting great things with ms.mvc
Requesting Gravatar... sawik Oct 04, 2009 1:16 AM
# re: ASP.NET MVC 2 Preview 2
I try to use ValidationMessageFor in my simple demo using ASP.NET MVC 2 Release 2 and got error. System.Web.Mvc installed doesn't contain this Html extenssion method. I see in the source code from codeplex, that it is in MvcFutures project but not in the System.Web.Mvc.

I would like to take advantage of using lamda expression with Html.EditorFor and Html.ValidationMessageFor because my ViewModel is complex and is subject to future refactoring, so having Strongly Typed UI Helpers would be nice.

Is the installer missing ValidationMessageFor functionality?
Requesting Gravatar... foobar Oct 04, 2009 2:43 PM
# re: ASP.NET MVC 2 Preview 2
Getting closer and closer to getting useful... yay!
Requesting Gravatar... shiju varghese Oct 05, 2009 12:52 AM
# re: ASP.NET MVC 2 Preview 2
Great Work and get improving the framework after every release.
Requesting Gravatar... Huthaifa Afanah Oct 05, 2009 2:42 AM
# re: ASP.NET MVC 2 Preview 2
Great work. BTW when VS2010 beta2 will be released.
Requesting Gravatar... Adam Hicks Oct 05, 2009 4:24 AM
# re: ASP.NET MVC 2 Preview 2
Been looking forward to this. Thanks for all the effort.
Requesting Gravatar... Bret Ferrier Oct 05, 2009 8:39 AM
# re: ASP.NET MVC 2 Preview 2
So when will Visual Studio 2010 Beta 2 be coming out
Requesting Gravatar... John Oct 07, 2009 9:21 AM
# re: ASP.NET MVC 2 Preview 2
I downloaded this version and build a new application. I have the following two challenges.
1. Data Annotation doesn't seem to work
2. When I create a partial class, I am getting Cannot implicitly convert type 'System.Data.Linq.Table<>' to 'System.Linq.IQueryable<>' error.

otherwise, I am enjoying MVC. Keep up the good work
Requesting Gravatar... Jack Oct 08, 2009 7:10 PM
# re: ASP.NET MVC 2 Preview 2
Another preview is coming, let's keep up with it!
Requesting Gravatar... Satu Thundathil Oct 09, 2009 7:12 AM
# re: ASP.NET MVC 2 Preview 2
Great.
Requesting Gravatar... dabai Oct 11, 2009 6:49 PM
# Bug ? Help me please!!!!!!
How can i used the generic view on areas project ?
when i create a view like :
<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<NetShop.Models.TModelList<NetShop.Entities.RoleEnt>>" %>

can't running , and the view page helper can't tooltip again.

bug ,i can used generic view on main project that not areas project.

wait for your online reply anxiously!
thank you !
Requesting Gravatar... dabai Oct 11, 2009 6:58 PM
# re: ASP.NET MVC 2 Preview 2
?????,???????????????,????????:

?areas????,??????view????????????view???,HtmlHelper????,????????????????:????System.Web.Mvc.ViewPage<NetShop.Models.TModelList<NetShop.Entities.RoleEnt>>,???????

??,???????????,????

What do you have to say?

(will show your gravatar)
Please add 3 and 2 and type the answer here: