ASP.NET MVC 2 (Release Candidate 2) Now Available

[In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu]

Earlier this evening the ASP.NET team shipped ASP.NET MVC (Release Candidate 2) for VS 2008/.NET 3.5.  You can download it here.

The RC2 release of ASP.NET MVC 2 is a follow-up to the first ASP.NET MVC 2 RC build that we shipped in December.  It includes a bunch of bug fixes, performance work, and some final API and behavior additions/changes.  Below are a few of the changes between the RC1 and RC2 release (read the release notes for even more details):

  • The new ASP.NET MVC 2 validation feature now performs model-validation instead of input-validation (this means that when you use model binding all model properties are validated instead of just validations on changed values of a model).  This behavior change was based on extensive feedback from the community.
  • The new strongly-typed HTML input helpers now support lambda expressions which reference array or collection indexes.  This means you can now write code like Html.EditorFor(m=>m.Orders[i]) and have it correctly output an HTML <input> element whose “name” attribute contains the index (e.g. Orders[0] for the first element), and whose “value” contains the appropriate value.
  • The new templated Html.EditorFor() and Html.DisplayFor() helper methods now auto-scaffold simple properties (and do not render complex sub-properties by default).  This makes it easier to generate automatic scaffolded forms.  I’ll be covering this support in a future blog post.
  • The “id” attribute of client-script validation message elements is now cleaner.  With RC1 they had a form0_ prefix.  Now the id value is simply the input form element name postfixed with a validationMessage string (e.g. unitPrice_validationMessage).
  • The Html.ValidationSummary() helper method now takes an optional boolean parameter which enables you to control whether only model-level validation messages are rendered by it, or whether property level validation messages are rendered as well.  This provides you with more UI customization options for how validation messages are displayed within your UI.
  • The AccountController class created with the default ASP.NET MVC Web Application project template is cleaner.
  • Visual Studio now includes scaffolding support for Delete action methods within Controllers, as well as Delete views (I always found it odd that the default T4 templates didn’t support this before).
  • jQuery 1.4.1 is now included by default with new ASP.NET MVC 2 projects, along with a –vsdoc file that provides Visual Studio documentation intellisense for it.
  • The RC2 release has some significant performance tuning improvements (for example: the lambda based strongly-typed HTML helpers are now much faster).

Today’s RC2 release only work with VS 2008 and .NET 3.5.  We’ll shortly be releasing the VS 2010 RC (which will be available for everyone to download). It will include ASP. NET MVC 2 support built-in (no separate download required).

Hope this helps,

Scott

P.S. The source code for the ASP.NET MVC RC2 release (along with a MVC futures library that goes with it) can be downloaded here. You can learn even more about ASP.NET MVC 2 by reading the ASP.NET MVC 2 blog series I’m working on.

Published Friday, February 5, 2010 12:44 AM by ScottGu
Filed under: , , ,

Comments

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 4:03 AM by horacebury

Any news on the fix to the TryUpdateModel problem, Scott? stackoverflow.com/.../asp-net-mvc-2-problem-with-updatemodel

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 4:17 AM by Maciej Aniserowicz

Hi Scott,

I have a question regarding this statement:

"the lambda based strongly-typed HTML helpers are now much faster"

Is there any place we can read more about this improvement - how it was achieved? (besides the source code itself of course:) ).

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 4:33 AM by Klaus Even Enevoldsen

I wonder how shortly are you releasing the VS 2010 RC? Is it a matter of hours, days or weeks? :-)

In other words; should I cancel my plans for the weekend?

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 4:46 AM by Iain Galloway

Thanks for all your hard work!

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 4:55 AM by Chris Hardy (ChrisNTR)

@horacebury - Since the code is open source - you can check out the source code and see if it's been fixed. You'll notice that it has been changed (the FormCollection GetValue problem) to fix this bug.

Cheers,

ChrisNTR

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 5:06 AM by Vladan Strigo

Hi Scott,

Any chance of getting model based scaffolded controllers (like we can have views)? This way we could make our own templates and very quickly generate CRUD's?

Also, any chance of multi templates? So that you could select from a list of template folders (that way we could create several templates for example for controllers...one for CRUD, one for normal controllers and such...), and then just use it as appropriate (something similar like you can select view content...list template, detail, etc...)

Thanks,

Vladan

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 5:13 AM by Howard van Rooijen

Hi,

RE: Html.ValidationSummary() I thought latest thinking was that "magic" boolean parameters were a bad thing & better practice was to actually supply a more descriptive Enum?

Thanks,

Howard

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 6:15 AM by rajbk

@horacebury

From the release notes:

"The GetValue method of the FormCollection class now allows empty string values."

-raj

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 6:18 AM by ignatandrei

Very good !

Thank you for "model-validation instead of input-validation"!

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 6:50 AM by Eduardo Mendes those

great!

I'll do some tests ^^

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 7:02 AM by ZippyV

One problem I encountered in MVC2 is with subfolders (containing css, images or js) in Areas. For example: mysite.com/admin/css/adminstyles.css. I tried creating a folder in projectroot/Areas/Admin/css/ and projectroot/Admin/css/ but neither worked when I tested my site.

Is there some solution for this?

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 7:10 AM by Felipe Oriani

Great news!

Cheers

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 7:13 AM by Simon Rigby

Hi Scott,

Yes I'm impatient .. grin. Any idea when VS 2010 RC will be released. The reason I ask is that I am currently making the move to MVC (for some non critical projects) and am currently working with VS2010 Beta 2 which I undrerstand is a little behind in the MVC area. Just wondered if I should abort VS 2010 Beta 2 for the moment and install MVC RC2 for VS 2008. But if the VS2010 RC is close I'll hold off.

Thanks.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 8:25 AM by Arnis L.

What a relief. Can't wait to migrate my app.

Thank you!

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 9:06 AM by Giedrius

What about migration from MVC1 to MVC2 RC2? So far i've seen only migration tool to beta, is it safe to use it to migrate to rc2?

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 10:32 AM by PWC

Thanks for the great work. We've really like MVC, and I think it's one of the best things MS had delivered!

Patrick

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 10:41 AM by NickLarsen

Html.EditorFor(m=>m.Orders[i])

Finally!

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 11:02 AM by alan huffman

Fantastic news! Thanks.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 11:37 AM by Deny

Hello, can I host MVC2 RC2 in ISS 7? I try this with MVC2 RC1, but it don't work. Thank you for answer.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 11:55 AM by salman.farsi.2010

Thanks for early release.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 12:40 PM by ScottGu

@horacebury

>>>>>>>> Any news on the fix to the TryUpdateModel problem, Scott? stackoverflow.com/.../asp-net-mvc-2-problem-with-updatemodel

Yes - I believe that is now fixed.  Let me know if you still run into issues with it.

Thanks,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 12:41 PM by atmonline

thanks for jQuery 1.4.1.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 2:10 PM by Steve Hebert

Great work guys - really excited for the Model Validation change.

As for this: Html.EditorFor(m=>m.Orders[i])

How about Html.EditorFor(m => m.Orders[i].Name) ?  will I end up with Orders[n].Name in the id/name tag (where [n] is the index number)?

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 3:26 PM by Darren

Anybody else not getting Intellisense for jQuery 1.4.1 in Visual Studio 2008 SP1 with the JS Intellisense patch installed?  I copied the old jQuery libraries from the previous MVC RC1 and Intellisense works.  But doesn't seem to work for version 1.4.1.  Is there something I'm missing?

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 3:36 PM by Mike C.

Ahhh can't wait for the new VS 2010 RC!!!

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 3:59 PM by Steve

Is there an upgrade path for asp.net mvc 1.0 in this ?

Also, I'm running 2010, can I roll back my project to 2008 then install this?

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 5:23 PM by o

How long is "shortly" in reference to VS 2010 RC, or can you not give us an exact date/estimate? Will it support ASP.NET MVC 2 RC 2 or just RC 1?

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 7:50 PM by Webdiyer

Congratulation! I'll update MvcPager to use asp.net mvc RC2.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Friday, February 5, 2010 8:14 PM by sikat ang pinoy

Creating silverlight on asp.net mvc are now easy. Thanks for the tutorials I like how you have presented the information in full detail. Keep up the great work

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 2:26 AM by Michel Miranda

Hi Scott,

How to make Html.EditorFor() render complex sub-properties?

[ScaffoldColumn(true)] isn't enough.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 9:16 AM by Saprelov

Yap. Intellisense dosnt work with jquery 1.4.1.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 1:32 PM by Kazi Manzur Rashid

The bullet point #3 is not what I expected and I think it will make the ModelMetadata very limited. As you have mention and also in the read me says it should work for complex object if any template file is used. But unfortunately it does not work even if you set a template file. For example if I have class with the follwing:

public class Product{

   public int Id { get; set;}

   public string Name { get; set;}

   public decimal Price { get; set;}

   [UIHint("myCustomTemplate")]

   public Category Category { get; set;}

}

And in my view (which uses the Product as Model ViewPage<Product>) if I use:

<%= Html.DisplayForModel() %>

If will not show the category only the Id, Name, Price will be shown.

I think this is somehow a show stopper for those who are thinking to create scaffolding framework to auto generate the UI.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:19 PM by ScottGu

@Maciej,

>>>>>>>>> Is there any place we can read more about this improvement - how it was achieved? (besides the source code itself of course:) ).

The source might be the best option (it is available for download too as a separate project).  I believe we added a bunch of caching logic to speed this up.

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:19 PM by ScottGu

@Klaus,

>>>>>>>>> I wonder how shortly are you releasing the VS 2010 RC? Is it a matter of hours, days or weeks? :-)

It won't be released this weekend.  But it will be soon... ;-)

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:21 PM by ScottGu

@Vladan,

>>>>>>> Any chance of getting model based scaffolded controllers (like we can have views)? This way we could make our own templates and very quickly generate CRUD's?  Also, any chance of multi templates? So that you could select from a list of template folders (that way we could create several templates for example for controllers...one for CRUD, one for normal controllers and such...), and then just use it as appropriate (something similar like you can select view content...list template, detail, etc...)

Those are definitely good suggestions and ones I think you'll see show up in the future.  For ASP.NET MVC 2 we unfortunately won't have this in the built-in controller dialog - but I expect others to probably create extensions that support this.

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:21 PM by ScottGu

@Howard,

>>>>>>>>> RE: Html.ValidationSummary() I thought latest thinking was that "magic" boolean parameters were a bad thing & better practice was to actually supply a more descriptive Enum?

Good comment.  I'll forward it along to the team to see what they say.

Thanks,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:22 PM by ScottGu

@ZippyV,

>>>>>>>> One problem I encountered in MVC2 is with subfolders (containing css, images or js) in Areas. For example: mysite.com/admin/css/adminstyles.css. I tried creating a folder in projectroot/Areas/Admin/css/ and projectroot/Admin/css/ but neither worked when I tested my site.

You should be able to do this.  How are you referencing the files?  Are you prefixing the css URL with a /Area/Admin/css prefix?

Thanks,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:23 PM by ScottGu

@Simon,

>>>>>>>>> Yes I'm impatient .. grin. Any idea when VS 2010 RC will be released. The reason I ask is that I am currently making the move to MVC (for some non critical projects) and am currently working with VS2010 Beta 2 which I undrerstand is a little behind in the MVC area. Just wondered if I should abort VS 2010 Beta 2 for the moment and install MVC RC2 for VS 2008. But if the VS2010 RC is close I'll hold off.

It will be out pretty shortly.  Stay tuned to my blog for details.

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:24 PM by ScottGu

@Gierdrius,

>>>>>>>>> What about migration from MVC1 to MVC2 RC2? So far i've seen only migration tool to beta, is it safe to use it to migrate to rc2?

There are migration notes in the release notes.  You can do it either manually (updating the project+references - should only take a few minutes).  VS 2010 will also include an automatic upgrade wizard that will help automate it.

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:24 PM by ScottGu

@Deny,

>>>>>>>> Hello, can I host MVC2 RC2 in ISS 7? I try this with MVC2 RC1, but it don't work. Thank you for answer.

This should just work.  What problem did you run into?

Thanks,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:25 PM by ScottGu

@Steve,

>>>>>>>>> How about Html.EditorFor(m => m.Orders[i].Name) ?  will I end up with Orders[n].Name in the id/name tag (where [n] is the index number)?

The good news is that this works as well.

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:26 PM by ScottGu

@Steve,

>>>>>>>> Also, I'm running 2010, can I roll back my project to 2008 then install this?

Yes - you could do that.  What you'd want to-do is to go to add/remove programs and uninstall the ASP.NET MVC 2 bits (the runtime + VS tools support for ASP.NET MVC items).  Then you can download and install the ASP.NET MVC 2 RC2 above and use it with VS 2008.

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:27 PM by ScottGu

@Michel,

>>>>>> How to make Html.EditorFor() render complex sub-properties?

I think you need to create a template for the object in order to render sub-properties.  I will ping the dev team to see if they've thought of adding a flag to EditorFor() that enables this too.

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 4:28 PM by ScottGu

@kazimanzurrashid,

>>>>>>>>>> The bullet point #3 is not what I expected and I think it will make the ModelMetadata very limited. As you have mention and also in the read me says it should work for complex object if any template file is used. But unfortunately it does not work even if you set a template file.

I think to render complex sub-properties you need to override the template for the object itself.  I'll ping the dev team, though, to see if there is a way with the RTM build to enable a flag for this too.

Hope this helps,

Scott

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Saturday, February 6, 2010 5:21 PM by Fisher

Ignore what I just said. I got vsdoc for jquery 1.4.1 from VS2008. But like some comments said. I cannot get intellisense as well. when typing js code in vs2010. Intellisense only shows function parameter without any comment.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Sunday, February 7, 2010 11:08 PM by Nick Riggs

False alarm - I see the problem now. You have to include /Areas/ in the URL... which makes perfect sense. My bad.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Tuesday, February 9, 2010 11:41 AM by Dan A

I just swapped out RC1 for RC2 in my application and model binding to a list appears broken. At least when you specify the index. Anyone else see this?

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Monday, February 15, 2010 1:45 PM by Waxalica

>>>>>>>>>>>>>>>> The new strongly-typed HTML input helpers now support lambda expressions which reference array or collection indexes.  This means you can now write code like Html.EditorFor(m=>m.Orders[i]) and have it correctly output an HTML <input> element whose “name” attribute contains the index (e.g. Orders[0] for the first element), and whose “value” contains the appropriate value.

This function does not work actually with the MVC version "shipped" in VS 2010 RC... Name output is "Orders"...

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Monday, February 15, 2010 1:49 PM by Waxalica

@Dan A

Was looking for binding a list... Had used a logic approach for naming fields :

Item[0].Property0

Item[0].Property1

Item[1].Property0

Item[1].Property1

And it works fine, without Index

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Tuesday, February 16, 2010 6:27 AM by Nasir

Hi, Thanks for latest release and Model level Validation. I have facing the following problem after the update.

I have a Model with Class level Validation plus property level validation in it. After updating to MVC 2 RC 2. The model validation fails on Model binding. What i actually understand that new mechanism trying to validate the model when you first request it or say on GET and it get null object exception during tryvalidatemodel Model binding call.

My Model is like this below

[Serializable]    

[MetadataType(typeof(InterestClaimMetaData))]   //metadata with all properties level validation

//these validations fails when you request a page.

[DateComparison("DateA", "DateB", eDateComparitor.GreaterThan, ErrorMessage = "Date A must be greater than B Date")][MutuallyExclusive("A", "B", ErrorMessage = "Please select either A or B field")]  

public class IE

   {

       public int ID { get; set; }

       public byte[] Updated { get; set; }

 }

DataComparison and MutuallyExclusive overrides the validate function isvalid and check the validation but it fails trying to validate as first requested.

dont know how to stop this happening as it should not validate model on get request; just attach the properties.

Only models without these class level validation works.

Please advise.

Thanks

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Sunday, February 28, 2010 10:59 AM by Eduardo Marin

What would be the problem that using Jason data and jQuery with MVC 1 works o.k. and the same functions using MVC 2 CR2 don't work ??

Example the using the jqGrid to show data in a grid running in MVC 1 works o.k. in the page you see the grid with the data passed by Jason from a action in controler. The same code with MVC 2 you see the grid in the page but empty. It's like it has a problem receiving the Jason data.

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Thursday, March 4, 2010 12:49 PM by Jackie yin

asp.net mvc 2 Not perfect,in Areas Should  Achieve 2 domain Route.Official Version To consider.

public class HomeAreaRegistration : AreaRegistration

  {

      public override string AreaName

      {

          get

          {

              return "Home";

          }

      }

      public override void RegisterArea(AreaRegistrationContext context)

      {

          context.MapRoute(

              "Home_default",

              "Home/{controller}/{action}/{id}",

              new { controller = "Home", action = "Index", id = "" },

              new string[] { "Ghaozi.HomeAreas.Controllers" }

          );

          // context.MapDomainRoute(

          // "Home_default",

         //    "{controller}.asp.net/{action}/{id}",                // URL with parameters

         //    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults

         // );

      }

  }

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Thursday, March 4, 2010 12:51 PM by Jackie yin

asp.net mvc 2 Not perfect,in Areas Should  Achieve 2 domain Route.Official Version To consider.

public class HomeAreaRegistration : AreaRegistration

  {

      public override string AreaName

      {

          get

          {

              return "Home";

          }

      }

      public override void RegisterArea(AreaRegistrationContext context)

      {

          context.MapRoute(

              "Home_default",

              "Home/{controller}/{action}/{id}",

              new { controller = "Home", action = "Index", id = "" },

              new string[] { "Ghaozi.HomeAreas.Controllers" }

          );

          // context.MapDomainRoute(

          // "Home_default",

         //    "{controller}.asp.net/{action}/{id}",                // URL with parameters

         //    new { controller = "Home", action = "Index", id = "" }  // Parameter defaults

         // );

      }

  }

# re: ASP.NET MVC 2 (Release Candidate 2) Now Available

Wednesday, March 17, 2010 10:29 AM by Mayweather

So that you could select from a list of template folders that way we could create several templates for example for controllers one for CRUD, one for normal controllers and such.