ASP.NET MVC 3 Beta Released

asp.net mvc, asp.net, code 0 comments suggest edit

UPDATE: This post is a out of date. We recently released the Release Candidate for ASP.NET MVC 3.

Wow! It’s been a busy two months and change since we released Preview 1 of ASP.NET MVC 3. Today I’m happy (and frankly, relieved) to announce the Beta release of ASP.NET MVC 3. Be sure to read Scott Guthrie’s announcement as well.

onward Credits: Image from ICanHazCheezburger http://icanhascheezburger.com/tag/onward/

Yes, you heard me right, we’re jumping straight to Beta with this release! To try it out…

As always, be sure to read the release notes (also available as a Word doc if you prefer that sort of thing) for all the juicy details about what’s new in ASP.NET MVC 3.

A big part of this release focuses on polishing and improving features started in Preview 1. We’ve made a lot of improvements (and changes) to our support for Dependency Injection allowing you to control how ASP.NET MVC creates your controllers and views as well as services that it needs.

One big change in this release is that client validation now is built on top of jQuery Validation in an unobtrusive manner. In ASP.NET MVC 3, jQuery Validation is the default client validation script. It’s pretty slick so give it a try and let us know what you think.

Likewise, our Ajax features such as the Ajax.ActionLink etc. are now built on top of jQuery. There’s a way to switch back to the old behavior if you need to, but moving forward, we’ll be leveraging jQuery for this sort of thing.

Where’s the Razor Syntax Highlighting and Intellisense?

This is probably a good point to stop and provide a little bit of bad news. One of the most frequently asked questions I hear is when are we going to get syntax highlighting? Unfortunately, it’s not yet ready for this release, but the Razor editor team is hard at work on it and we will see it in a future release.

I know it’s a bummer (believe me, I’m bummed about it) but I think it’ll make it that much sweeter when the feature arrives and you get to try it out the first time! See, I’m always looking for that silver lining. ;)

What’s this NuPack Thing?

That’s been the other major project I’ve been working on which has been keeping me very busy. I’ll be posting a follow-up blog post that talks about that.

What’s Next?

The plan is to have our next release be a Release Candidate. I’ve updated the Roadmap to provide an idea of some of the features that will be coming in the RC. For the most part, we try not to add too many features between Beta and RC preferring to focus on bug fixing and polish.

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

Comments

avatar

46 responses

  1. Avatar for Dan Appleyard
    Dan Appleyard October 5th, 2010

    This sounds fantastic! Can't wait to get my hands dirty on the beta and NuPack!

  2. Avatar for Rob White
    Rob White October 5th, 2010

    NuPack sounds interesting, are you going to do a compare and contrast with other package managers?

  3. Avatar for Chad Moran
    Chad Moran October 5th, 2010

    Thanks Phil and co, great stuff.
    Are the caching improvements still slated for the final release of MVC 3?

  4. Avatar for Travis
    Travis October 5th, 2010

    So Razor Syntax highlighting wont be in MVC3 final? Or just wont be in this beta release?

  5. Avatar for Ben
    Ben October 5th, 2010

    Don't forget about the temp solution of the razor syntax highlighter available from the Visual Studio Gallery.

  6. Avatar for JC Grubbs
    JC Grubbs October 5th, 2010

    What about the source code? Any word on when that will be released?

  7. Avatar for shawn
    shawn October 5th, 2010

    Wow, you're iterating public releases quickly!
    Any chance ASP.NET MVC 3 will have better support for binding to hierarchical model graphs, where the model contains sub-collections of other models? Right now the default model binder will clear out and re-create any existing collections rather than updating them.
    Rudi Breedenraedt came up with a nice workaround, it would be great to see something like that baked into MVC 3. Search for "asp.net mvc binding model graphs" for the example/workaround (which you commented on).

  8. Avatar for Fujiy
    Fujiy October 5th, 2010

    I need to reference all .js of ASP.NET MVC 2 plus this new? Or I can remove MicrosoftAjax.js, etc?
    Thanks

  9. Avatar for Erx
    Erx October 6th, 2010

    This is very dismal, I see now that there will be no feature to return multiple views in mvc 3.0, or even an elegant way to update various divs without having to make multiple requests (which force js hackery to request and blatant js hackery to split up and re assign on the receive end)... I still find it hard to believe that such a common need is not only ignored but not even acknowledged.

  10. Avatar for stuhin
    stuhin October 6th, 2010

    It is a pity that you have removed optional of @RenderSection((
    Now @RenderSection("content",optional:true) - ERROR

  11. Avatar for Matt S.
    Matt S. October 6th, 2010

    @Erx
    Are you eluding to a feature that will allow a single request to respond with multiple distinct views that can be targeted to areas of a primary view; like child views or multiple partial views that can be slipped into separate chunks of the main view?

  12. Avatar for Hector Minaya
    Hector Minaya October 6th, 2010

    Where is the RoadMap???

  13. Avatar for Fujiy
    Fujiy October 6th, 2010

    @Hector Minaya, the roadmap is at codeplex: aspnet.codeplex.com/wikipage?title=Road%20Map

  14. Avatar for Sean Paul
    Sean Paul October 6th, 2010

    Weird issue I found today when playing with the newest release. If I'm using the Authorize attribute on a Action when it goes to redirect to the Login action it is always redirecting to Account\Login and not reading the Forms authentication setup in the web.config. For instance with just a default project created from the new MVC3 Template add the authorize attribute to the Index method and run the site. It will throw a 404 page not found error saying it can't find the Account/Login page where it should be going to the Account/LogOn page.

  15. Avatar for George
    George October 6th, 2010

    Why did you remove the optional:true in RenderSection?? :(

  16. Avatar for haacked
    haacked October 6th, 2010

    @George @Stuhin. The Razor team simply inverted the parameter name. Here's what you need to do now. Turns out, it couldn't be named "optional" because VB.NET already uses that as a keyword. :)

    @RenderSection("content", required: false)

  17. Avatar for haacked
    haacked October 6th, 2010

    @Travis just for this beta release.

  18. Avatar for haacked
    haacked October 6th, 2010
  19. Avatar for Ignat Andrei
    Ignat Andrei October 6th, 2010

    Could you show/blog some examples about Tasked based helpers ?

  20. Avatar for Wayne Brantley
    Wayne Brantley October 6th, 2010

    (I posted this on Brad's blog too - wanted your input also)
    Any improvement in validation support?
    1) Need to set a range - dynamically. Say you are transferring money out your bank account. You click on the account you want to transfer from and I have a box to type in how much you want to transfer. In the controller - I can look at your balance and need to be able to set the max value at that time. It does me no good to use a static attribute.
    2) Out of the box support for remote validation.
    3) Put a from and to date field on a page. Make sure the from is before the to. Or have 3 or 4 date fields that are all related, say - date you are leaving on vacation, date you are returning, date you want to fly home. (leave<return, flyhome>=leave and flyhome<return)
    4) Model validation - validate the model after all fields have been validated - and some way to send a javascript version of this to the client.
    Are there any plans for implementation of any of these scenarios. I know I read there is some additional support for 'related field validation' in the preview (would it support option 3 above?). What about the badly needed option 1 and 2?

  21. Avatar for Gorazd Breskvar
    Gorazd Breskvar October 6th, 2010

    Will MVC3 support readonly concurrent session handling
    using
    [ControllerSessionState(ControllerSessionState.ReadOnly)] or will that part still be in MVC Futures?
    Here are more details on this issue:
    blog.whiletrue.com/...

  22. Avatar for Bm
    Bm October 6th, 2010

    Phil, we need multiple views support in mvc, or a way to update multiple divs in one request like erx mentioned. This should have been in since v1 :). Anyone else think this is important?
    At the moment I am queuing my requests, div one updates and sends js request to update div2 so user sees delay... Still better than the js hack option.

  23. Avatar for Sean Paul
    Sean Paul October 6th, 2010

    My question above is answered on Scott Guthrie's blog in one of his comments. Here is what he said.
    Wednesday, October 06, 2010 6:03 PM by ScottGu
    You found a bug! To work around it, add the following entry into your web.config file:
    <appSettings>
    <add key="autoFormsAuthentication" value="false" />
    </appSettings>
    (<appSettings> is a child element of <configuration>, not of <system.web>.)
    This should fix it.
    Thanks,
    Scott

  24. Avatar for Danny Fafach
    Danny Fafach October 6th, 2010

    I'm thrilled! Great work!
    BTW, it looks like this is a typo in the release notes under the section "Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3". Step 5 reads, "...add a reference to System.WebPages.dll and System.Web.Helpers.dll."
    This should reference "System.Web.WebPages.dll".
    Thanks,
    -Danny

  25. Avatar for Danny Fafach
    Danny Fafach October 6th, 2010

    Two thought:
    1. In the Application_PostAuthenticateRequest() method of my Global.asax.cs file I am referencing Context.User.Identity. This install caused this identity to come back as null every time I hit a page. However, Sean's post about adding <add key="autoFormsAuthentication" value="false" /> to my Views\Web.config file fixed the problem. Thanks Sean/Scott!
    2. I am getting the following runtime error on a @using directive on the top of a cshtml file:
    System.Web.HttpParseException was unhandled by user code Message=Expected ";"
    If I add a semicolon to the @using directive the error goes away, but then I get a ";" on my page. Adding <!-- @using namespace; --> doesn't hide the semicolon either :( Any suggestions?
    Thanks,
    Danny

  26. Avatar for Lee
    Lee October 7th, 2010

    Hi Phil, i'm loving the improvements. I'm quite new to ASP.NET MVC but kind of jumped in at the deep end by starting a new project with MVC to learn it. Coming from ASP.NET Web Forms i particularly found it easy working with javascript. In ASP.NET v4 Web Forms we can now override the ClientID for any control but i believe this is not possible with the HTML helpers in MVC. I tend to name all my client id's lower case and separated by a hyphon. It would be great if there was a way to override the current naming conventions (preferably in one place).

  27. Avatar for Sean Paul
    Sean Paul October 7th, 2010

    @Danny, I hear you, going into all views and adding semicolons is no fun, I had to do it. My views are working fine with a ";" it doesn't show ";" on the page. But anyways, the new razor syntax for commenting is
    @*{comment text here}*@

  28. Avatar for Germ&#225;n
    Germ&#225;n October 7th, 2010

    Hi!,
    Great bits!! Anyway, following the _ViewStart.cshtml feature for centralizing the Layout setting is a litte bit tricky.
    It broke my application as the _Layout.cshtml itself is making various @Html.Action helper calls. This calls return also view (which is intended to be partial, no layout) but now with the layout globally defined they also execute the layout. So my application is making recursive calls to the @Html.Action helpers and it hangs.
    I solved it by going to these views that are intended to be partial views and wrote.
    @{
    Layout = null;
    }
    This solved my problem but I think there should be a clear mechanism for marking a view as a partial view that shouldn't get any layout, no matter what a site wide setting as the _ViewStart.cshtml Layout should have been defined.
    Maybe a @nolayout directive? A view naming convention?
    Great work, anyway. Regards.
    Germán

  29. Avatar for Germ&#225;n
    Germ&#225;n October 7th, 2010

    Hi,
    In regard to my previous issue, thinking for two additional seconds brought me to the real problem and the solution. In the action that was being called in the layout I was returning a normal View(). Changing it to PartialView() solved the issue an it clearly tells MVC that you don't want any layout no matter what the Razor's Engine Layout setting has been configured.
    ActionResult TopMenu() {
    var model = GetMenu();
    return PartialView(model);
    }
    Germán

  30. Avatar for Germ&#195;&#161;n
    Germ&#195;&#161;n October 7th, 2010

    Hi Phil,
    I can't access WebViewPage.Html property from within a declarative helper (@helper) in the same cshtml file, because razor generates a static HelperResult member for the helper section. So the wrapped delegate can't access the instance members of the WebViewPage.

    Example: This gives a nice compilation error CS0120 :-)
    @helper MyPopulatedTextBox(string name) {

    Hi @name!



    Is this your name? @Html.TextBox("theName", name)


    }
    <h2>@View.Message</h2>


    To learn more about...
    MyPopulatedTextBox("John Doe");


    Anyway, is there a central place to report all this issues for the Beta so your blog doesn't get bloated of boring comments like this one?
    Thanks!
    Germán

  31. Avatar for Justin
    Justin October 8th, 2010

    Hi Phil,
    I'm having a difficult time getting the razor view to look clean while simultaneously generate the HTML I want. The problem, for me, is in the way the white space is handled. Is there a way to stop razor from capturing white space to use in the generated output? Like @{ WhiteSpace.Ignore(); } then later turn back on white space capturing @{ WhiteSpce.Capture(); }
    Thanks,
    Justin

  32. Avatar for jmorris
    jmorris October 8th, 2010

    When is the MVC 4 CTP coming out?

  33. Avatar for Areg Sarkissian
    Areg Sarkissian October 8th, 2010

    Will the Razor View Engine support donut caching as apposed to donut hole caching?

  34. Avatar for Steve
    Steve October 9th, 2010

    I'm wondering why a grid was released but is client side sorting and paging only ? Quite honestly, you might as well push the MvcContrib grid instead as it offers much more. This is a very weak control being released.
    I suggest making sure when this goes live that these controls are rich, useful, and fully functional.
    Otherwise, just punt to people in the community (also Telerik) create good controls.
    Just waiting for a young dev to through this on the page with mvc/matrix and through a 1000 records at it without understanding the implications

  35. Avatar for Paul
    Paul October 10th, 2010

    I know it's cool to be releasing(or getting close) in 6months since V2, but geez it's getting hard to keep up.

  36. Avatar for Harlan Vossos
    Harlan Vossos October 10th, 2010

    How do you add global namespace imports for razor views? with aspx views namespaces added in the web config via the pages/namespaces setting were available. With MVC 3 preview 1, razor views could see namespaces added programitically using Microsoft.WebPages.Compilation.CodeGeneratorSettings.AddGlobalImport("") -- It appears this method no longer is available.

  37. Avatar for Justin
    Justin October 11th, 2010

    @Harlan you can use System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport("") for global namespace imports.

  38. Avatar for Germ&#225;n
    Germ&#225;n October 11th, 2010

    @Harlan, you can configure the namespaces through a new configuration section in web.config . Have a look at the default MVC 3 project and find in ~/Views/Web.config the following section

    <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
    <namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    </namespaces>
    </pages>
    </system.web.webPages.razor>

    Saludos!

  39. Avatar for Stacey
    Stacey October 11th, 2010

    One thing I would really like to see with MVC 3.0 is much more intuitive support for Multi-Select Drop Downs. I realize there are half a dozen to the other solutions out there, but it seems that no matter what, it always becomes a problem in any project I do.
    I would really be excited to see the MVC team address this in the future.
    One thing I haven't liked about MVC 3.0 is that a lot of the features that are being touted are very unclear. What I mean by that is that they assume a very specific level of knowledge in certain aspects of "MVC", such as Dependency Injection, and IoC. I realize that from a technical community standpoint, you cannot just 'dumb down' every post made, but I feel that a lot of blog posters do not keep in mind that MANY MANY MANY of the people 'getting into MVC programming', like myself, are very unfamiliar with these concepts and the way they are presented makes it hard to understand their significance. I know I spent a great deal of time reading through ScottGu's posts on MVC 3.0 and I find myself just saying "I have no idea what any of this means".
    In any case, I love how MVC 3.0 is shaping up. Keep up the good work. In all the years I've been programming, I've never seen a project evolve as quickly, and as professionally as ASP.NET MVC. I feel like we have a team that wants to make this a champion. I feel like we have a team that wants this to be a standard. I feel like we have a team that isn't cutting corners to get things done. When the MVC team releases something, it feels concrete, it feels thought out, it feels like something I can be proud to say I am using.

  40. Avatar for Erx
    Erx October 13th, 2010

    @matt s, and @Phil: yes This is whAt I am saying, or just a proper way to be able to update multiple divs especially if one div is one top and one on bottom we have to return everything in between as a partial view to update both divs in an Ajax call. Or we split the incoming using very hackie js methods. Ideally there should be a proper way to update multiple divs in one show like the update panel in web forms allowed.
    @Phil:
    Will this be available in mvc3 final?

  41. Avatar for Venkat
    Venkat October 15th, 2010

    Where can i find source code for asp.net beta. In codeplex I am able to find source code for only MVC3 preview1.

  42. Avatar for Viewguy
    Viewguy October 17th, 2010

    I would also like to know if updating multiple divs in one Ajax request will be available in mvc3 final

  43. Avatar for Maxild
    Maxild October 28th, 2010

    Just browsed the source for MVC 3. A lot of new code!
    I am going to investigate further but the dependencies and the duplication seems a bit weird for a start.
    What is this new System.Web.WebPages and System.Web.WebPages.Razor that MVC needs to build and run?
    Is it really necessary to understand for a guy using a 3rd party view engine?
    And why can't Razor be brought in -- from my code -- without a reference to System.Web.Razor in System.Web.Mvc? I mean, if I like to try Razor my web app project will reference it and bootstrap the engine probably referencing System.Web.Razor and 'System.Web.Mvc.Razor' (an assembly name i made up for mvc specific 'adapter' code).
    Maybe this is a subject for another blog post.
    P.S. Thanks for always make a preview of the source available

  44. Avatar for Igorbek
    Igorbek October 29th, 2010

    I found 2 bugs in Razor view-engine.
    1. I can't write any inline-templates in _ViewStart, cause
    WriteLitralTo is not defined in ViewStartPage class
    2. Translator inserts unnecessary whitespace writes
    For ex:
    _ViewStart.cshtml
    @{
    Func<int, HelperResult> intFormatter = @<text>- @item -</text>;
    }
    That code translates to:
    public class _ViewStart_cshtml : System.Web.Mvc.ViewStartPage {
    ...
    public override void Execute() {
    Func<int, HelperResult> intFormatter =item => new
    System.Web.WebPages.HelperResult(__razor_template_writer => {
    WriteLiteralTo(@__razor_template_writer, " ");
    WriteLiteralTo(@__razor_template_writer, "- ");
    WriteTo(@__razor_template_writer, item);
    WriteLiteralTo(@__razor_template_writer, " -");
    }
    }
    }
    So:
    (1)
    CS0103: The name 'WriteLiteralTo' does not exist in the current context
    WriteLiteralTo is defined in System.Web.WebPages.WebPageBase, but
    StartPage does not inherited from it.
    (2)
    Why these unnecessary WriteLiteralTo calls (" ")? - there is no in my
    code. And these unnecessery calls occurs all the time even in other
    views! Why? I don't need them!
    If I change the code, by replacing single space by other spaces (for
    ex, three tabs) between = and @:
    Func<int, HelperResult> intFormatter = @<text>- @item -</text>;
    translator generates:
    WriteLiteralTo(@__razor_template_writer, "\t\t\t");
    WriteLiteralTo(@__razor_template_writer, "- ");
    ...
    so, it generates writes for whitespaces BEFORE @, from code context!
    why? Is this bug?
    Is this behaivor will be changed to release?
    How to decide these problems?

  45. Avatar for Alexander Taran
    Alexander Taran October 31st, 2010

    I know you will look into publishing scenarios later in the cicle closer to release, but meanwhile I have to report that now "publish" from within vs2010 does not include most of cshtml files, even more it confused me with including some of them.
    should be more consistent way to include all assemblies needed to run mvc3 razor website into bin directory.
    Keep up the good work. MVC is awesome.

  46. Avatar for borgman
    borgman November 1st, 2010

    When is Intellisense-support coming? Could you give a rough estimate?