ASP.NET MVC 2 Preview 2

0 comments suggest edit

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.

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.



38 responses

  1. Avatar for James Curran
    James Curran September 30th, 2009

    That's so cool that you've included jQuery validation.

  2. Avatar for Martin MacPherson
    Martin MacPherson September 30th, 2009

    Speaking of VS 2010 Beta 2, any ideas when it is set to be released?
    (I gotta ask ;)

  3. Avatar for Fujiy, Felipe
    Fujiy, Felipe September 30th, 2009

    jQuery client side validation will be helpfull.

  4. Avatar for Khaja Minhajuddin
    Khaja Minhajuddin September 30th, 2009

    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?

  5. Avatar for Kieron Lanning
    Kieron Lanning September 30th, 2009

    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?

  6. Avatar for Bart Plasmeijer
    Bart Plasmeijer September 30th, 2009

    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.

  7. Avatar for Joe
    Joe September 30th, 2009

    Is the final of MVC 2 going to be released before VS 2010 at all, or both together?

  8. Avatar for Betty
    Betty September 30th, 2009

    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.

  9. Avatar for KevDog
    KevDog September 30th, 2009

    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.

  10. Avatar for zihotki
    zihotki September 30th, 2009

    Could you please fix a link to Release Notes? At the moment it links to .

  11. Avatar for Victor
    Victor September 30th, 2009

    I would like to know more about Model Validation and Metadata providers ;)

  12. Avatar for Vijay Santhanam
    Vijay Santhanam September 30th, 2009

    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 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

  13. Avatar for Bob
    Bob September 30th, 2009

    According to the Release Notes, this cannot be installed alongside MVC 1. Is that really true?

  14. Avatar for Piers Lawson
    Piers Lawson September 30th, 2009

    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!

  15. Avatar for Craig Stuntz
    Craig Stuntz September 30th, 2009

    Very nice. Thanks for the frequent and early shipments!

  16. Avatar for Matt Hidinger
    Matt Hidinger September 30th, 2009

    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!

  17. Avatar for lynn
    lynn October 1st, 2009

    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?

  18. Avatar for Haacked
    Haacked October 1st, 2009

    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.

  19. Avatar for Mario
    Mario October 1st, 2009

    Hi Phil,
    Do you know how many previews they will be before release?

  20. Avatar for Dmitriy Nagirnyak
    Dmitriy Nagirnyak October 1st, 2009

    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?

  21. Avatar for Dario-g
    Dario-g October 1st, 2009

    When GoLive???

  22. Avatar for Diego
    Diego October 1st, 2009

    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.

  23. Avatar for Shaharyar
    Shaharyar October 1st, 2009

    Is there any support for automatic paging planned for the upcoming releases?

  24. Avatar for yemek tarifleri
    yemek tarifleri October 2nd, 2009

    Great news.

  25. Avatar for Mike
    Mike October 2nd, 2009

    "in a manner similar to the xVal validation framework"
    Reinventinging the wheel much lately?

  26. Avatar for Gauthier Segay
    Gauthier Segay October 2nd, 2009

    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

  27. Avatar for sawik
    sawik October 3rd, 2009

    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?

  28. Avatar for foobar
    foobar October 4th, 2009

    Getting closer and closer to getting useful... yay!

  29. Avatar for shiju varghese
    shiju varghese October 4th, 2009

    Great Work and get improving the framework after every release.

  30. Avatar for Huthaifa Afanah
    Huthaifa Afanah October 4th, 2009

    Great work. BTW when VS2010 beta2 will be released.

  31. Avatar for Adam Hicks
    Adam Hicks October 4th, 2009

    Been looking forward to this. Thanks for all the effort.

  32. Avatar for Bret Ferrier
    Bret Ferrier October 4th, 2009

    So when will Visual Studio 2010 Beta 2 be coming out

  33. Avatar for John
    John October 6th, 2009

    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

  34. Avatar for Jack
    Jack October 8th, 2009

    Another preview is coming, let's keep up with it!

  35. Avatar for Satu Thundathil
    Satu Thundathil October 8th, 2009


  36. Avatar for dabai
    dabai October 11th, 2009

    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 !

  37. Avatar for dabai
    dabai October 11th, 2009


  38. Avatar for sammy
    sammy March 8th, 2015

    I love to code so much, it breaks my heart to see what programmer culture lets pass as responsible coding and design. I love to code so much that I can barely bring myself to participate anymore. It's deeply depressing and soul-crushing.