Announcing the ASP.NET MVC 3 Release Candidate

This morning the ASP.NET team shipped the ASP.NET MVC 3 RC (release candidate). You can download it here.

ASP.NET MVC 3 is a pretty sweet release, and adds a ton of new functionality and refinements.  It is also backwards compatible with ASP.NET MVC V1 and V2 – which makes it easy to upgrade existing apps (read the release notes for the exact steps to do so).  You can learn more about some of the great capabilities in ASP.NET MVC 3 from previous blog posts I’ve done about it:

Today’s ASP.NET MVC 3 RC build includes several additional feature refinements (in addition to bug fixes, tooling improvements, perf tunings, etc).  This blog post covers the improvements specific to today’s release.  Please review my previous posts to learn more about the many, many other ASP.NET MVC 3 features and improvements introduced in prior previews/betas.

Razor Intellisense within Visual Studio

Colorization and intellisense support for Razor-based view templates is now supported within Visual Studio and the free Visual Web Developer Express. 

Intellisense works for HTML, C#, VB, JavaScript and CSS when editing within razor based view templates:

image

You get full C#/VB code intellisense – including against HTML helper methods (all of the existing Html helper methods in ASP.NET MVC also work just fine in Razor based views):

image

We also provide intellisense for Razor keywords and directives:

image

Note below how after setting the @model directive to be a Product, the strongly-typed HTML helpers (and the “Model” property within the template) are now typed correctly to provide intellisense for a “Product” class:

image

We are still doing final performance tuning on the editor (and have several optimizations that just missed today’s build).  If you encounter a scenario where intellisense either doesn’t seem to work or seems slower than it should be – please send us a repro so that we can verify that our latest builds have it fixed.

NuGet Package Manager

I blogged about a new, free, open source package manager last month - which at the time we were calling “NuPack”.  We’ve since renamed NuPack to NuGet. Today’s ASP.NET MVC 3 release automatically installs it as part of the setup.

You can use NuGet to easily download and install both commercial and open source libraries within your projects.  For example, to install NHibernate and a LINQ extension library that someone has built for it, I could type “install-package NHibernate.Linq” within the NuGet package manager console inside Visual Studio:

image

When I press enter NuGet will automatically download all of the libraries (and their dependencies) and setup my ASP.NET MVC 3 project to use them:

image

There are now hundreds of open source .NET libraries within the NuGet package feed, and the list will continue to grow over time. 

We think NuGet will enable all .NET developers (not just ASP.NET MVC ones) to be able to more easily leverage and share functionality across the community, and make building .NET  applications even better. 

Watch Scott Hanselman’s PDC Talk

Scott Hanselman gave the highest-rated talk at PDC this year, which he called “ASP.NET + Packaging + Open Source = Crazy Delicious”.  It is a “no slides” talk that demonstrates how to code an application from start to finish using ASP.NET MVC 3, Razor, NuGet, EF Code First, SQL CE and a bunch of other cool things.

image

You can watch the talk online or download it (by right-clicking and choosing “save as” from one of the links below):

- Low Bandwidth WMV Video (about 258 megs)

- Low Bandwidth MP4 Video (about 120 megs)

I highly recommend watching it – it is both entertaining, and demonstrates how all the pieces of the ASP.NET MVC 3 stack (and especially NuGet) fit together.

Partial Page Output Caching

ASP.NET MVC has supported output caching of full page responses since V1.  With ASP.NET MVC V3 (starting with today’s RC) we are also enabling support for partial page output caching – which allows you to easily output cache regions or fragments of a response as opposed to the entire thing.  This ends up being super useful in a lot of scenarios.

Output caching just a region of a page is really easy to-do.  Simply encapsulate the region you want to output cache within a child action that you invoke from within the view that you are rendering.  For example, below I have a product listing page, and I want to output a “Daily Specials” section on the page as well:

image

Above I’m using the Html.Action() helper method to call the SalesController.DailySpecials() child action method.  Notice that I’m passing a category parameter to it above – which will allow me to customize the “Daily Specials” I display based on what types of products the user is currently browsing (that way if they are browsing “computer” products I can display a list of computer specials, and if they are browsing “baby” products I can display diaper specials).

Below is a simple implementation of the SalesController.DailySpecials() method.  It retrieves an appropriate list of products and then renders back a response using a Razor partial view template:

image

Notice how the DailySpecials method above has an [OutputCache] attribute on it.  This indicates that the partial content rendered by it should be cached (for 3600 seconds/1 hour).  We are also indicating that the cached content should automatically vary based on the category parameter.

If we have 10 categories of products, our DailySpecials method will end up caching 10 different lists of specials – and the appropriate specials list (computers or diapers) will be output depending upon what product category the user is browsing in.  Importantly: no database access or processing logic will happen if the partial content is served out of the output cache – which will reduce the load on our server and speed up the response time.

This new mechanism provides a pretty clean and easy way to add partial-page output caching to your applications.

Unobtrusive JavaScript and Validation

I discussed several of the validation and JavaScript/AJAX improvements coming in ASP.NET MVC 3 with in my blog post about the first ASP.NET V3 preview release.

One of the nice enhancements with ASP.NET MVC V3 is that the AJAX and Validation helpers in ASP.NET MVC now both use an unobtrusive JavaScript approach by default. Unobtrusive JavaScript avoids injecting inline JavaScript into HTML markup, and instead enables cleaner separation of behavior using the new HTML 5 “data-“ convention (which conveniently works on older browsers – including IE6 - as well). This makes your HTML smaller and cleaner, and makes it easier to optionally swap out or customize JS libraries.  The Validation helpers in ASP.NET MVC 3 also now use the jQueryValidate plugin by default.

Client Side Validation On By Default

With previous versions of ASP.NET MVC (including last month’s ASP.NET MVC V3 beta) you needed to explicitly call Html.EnableClientValidation() within your views in order to enable client-side validation to take place.  Starting with today’s RC that is no longer required, and client-side validation (using an unobtrusive approach) is now enabled by default (you can turn this off if you want through a config setting in web.config).

You do still need to reference the appropriate jQuery+jQuery Validation libraries within your site for the client-side validation to light-up.  Because you explicitly reference the JavaScript files, you can choose to either host them on your own server or reference them from a CDN (content delivery network) like Microsoft’s or Google’s. 

Remote Validator

An additional validation feature that is new with today’s RC is support for a new [Remote] validation attribute that enables you to take advantage of the jQuery Validation plug-in’s remote validator support.  This enables the client-side validation library to automatically call a custom method you define on the server to perform validation logic that can only be done server-side.  It provides a very clean way to integrate scenarios like this within your client-side validation experience.

Granular Request Validation

ASP.NET MVC has built-in request validation support that helps automatically protect against XSS and HTML injection attacks.  Sometimes, though, you want to explicitly turn off request validation for some scenarios where you want users to be able to post HTML content (for example: blog authoring or CMS content editing). 

You can now add a [SkipRequestValidation] attribute to models or viewmodels that disables request validation on a per-property basis during model binding:

image

Adding the above attribute to your model/viewmodel enables you to set it once and have it apply in all scenarios.

Other Improvements in the RC

Below is a partial list of other nice improvements in today’s RC:

Improved “New Project” Dialog Box:

When you create an ASP.NET MVC 3 Project you are presented with a dialog like below:

image

The above dialog is now extensible, and you can add additional starter templates, view engines, and unit test project frameworks to it.  We’ll be releasing additional starter templates over time (that will show up in the list) to make it even easier to get up and running on new projects.

Scaffolding Improvements

A number of small, but nice, improvements have been made to the default ASP.NET MVC scaffold templates.  The templates now do a better job of identifying ID/Primary Key properties on models, and handle them appropriately (for example: they now create appropriate links for edit/delete/etc).  The Create/Edit scaffolds also now use Html.EditorFor() by default instead of Html.TextBoxFor() – which makes it easier for you to customize/tweak how your models are displayed.

Add-View Dialog Box Improvements

When you use the Add->View dialog box to add a view that is strongly-typed, the Add View dialog box now filters out more non-applicable types and is sorted/organized in a way that makes it easier to find what you are looking for.

Session-less Controller Support

You can now indicate whether you want a Controller class to use session-state – and if so whether you want it to be read/write or readonly. 

Razor Model Dynamic By Default

If you do not specify a @model directive within your Razor views, the “Model” property on the page will now default to dynamic instead of object.  This enables you to perform late-binding against the model type.  Previously you had to add a ‘@model dynamic” to the top of the file to do this.

New Overloads for Html.LabelFor() and Html.LabelForModel()

New method overloads have been added for the LabelFor() and LabelForModel() helper methods that enable you to optionally specify or override the label text.

Download

A direct link to an installer for the ASP.NET MVC 3 RC can be found here.  It works with both VS 2010 and the free Visual Web Developer 2010 Express.

Please make sure to uninstall any previous ASP.NET MVC 3 releases you have installed on your system (as well as any previous ASP.NET Web Pages setups that you might have installed).

Summary

Today’s ASP.NET MVC 3 RC build contains a bunch of goodness that makes web development with ASP.NET MVC better than ever.  If you have questions or suggestions about the release, or find issues/bugs with it, please post them to the ASP.NET MVC forum on www.asp.net.  The ASP.NET MVC team monitors this forum closely and will be able to help.

We plan on spending the next few weeks monitoring feedback, tuning performance, and fixing the final set of bugs.  Thanks in advance for any issues you send our way!

Hope this helps,

Scott

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

190 Comments

  • The current link to download ASP.NET MVC 3 RC isn't working :/

  • Vous avez fait un boulot enorme, bravo ! cette version est très prometteuse

  • Very nice, looking forward to trying it out. These are very interesting times for .NET developers... ;)

  • The url to download here - doesnt work Scott.

    Cheers
    Gregor

  • Thank the lord and your team. Intellisence for Razor is here. Great work guys.

  • When the final release date ?

  • @Michael,

    The download might still be propagating to the server you hit. Try again in a few minutes and it should work. If you continue to have problems send me email (scottgu@microsoft.com)

    Thanks,

    Scott


  • out of the subject :

    using the rss feed on google home page for reading your lastest posts,
    but the widget remains stuck on this post and older ones :

    Update on ASP.NET Vulnerability .... ??????

  • This release of ASP.NET MVC tremendously improved the web application development experience. Thanks for inventing Razor and all of the other stuff!

  • hy Scott, great work as usual, but please, leave me a cuoriosity, what is doing the setup procedure of asp.net mvc3... it take a lot of time, seem i'm installing office or reinstalling visual studio.
    Best regards and thank you again.

  • Does ASP.NET MVC 3 RC come with a go-live license?

  • Hi Scott,
    I just installed the RC, but I'm not getting intellisense in Razor views -- even in a newly created MVC3 project.

    Is there some additional config that needs to be done when upgrading from the Beta?

  • Nevermind, I was able to get intellisense working after going to tools > options > text editor > all languages and turning on statement completion options (for some reason they were off previously for me).

  • Congrats to the team !

    ASP.NET MVC is really cool.

  • @Gregor,

    >>>>>> The url to download here - doesnt work Scott.

    Can you try again to see if it is working now? I think the replication to some of the remote servers might have been delayed - it should work now. If you still see the issue make sure you do a deep refresh of the page (Ctrl+F5 on IE) as the link might be cached in your browser. And let me know if you still have problems with it.

    Hope this helps,

    Scott

  • @J.-Luc

    >>>>>>> When the final release date ?

    We haven't announced one just yet - waiting to see feedback on today's RC first :) It isn't too far off though.

    Hope this helps,

    Scott

  • @stefac,

    >>>>>>> hy Scott, great work as usual, but please, leave me a cuoriosity, what is doing the setup procedure of asp.net mvc3... it take a lot of time, seem i'm installing office or reinstalling visual studio.

    Most of the time is spent installing the VS tools update. That requires applying a VS patch - which takes awhile (because of how patching works). Sorry about that!

    Scott

  • @James Foster,

    >>>>>>> Does ASP.NET MVC 3 RC come with a go-live license?

    Yes - the ASP.NET MVC 3 RC does support a go-live license. You can start using it in production now.

    Hope this helps,

    Scott

  • @James,

    >>>>>>> Nevermind, I was able to get intellisense working after going to tools > options > text editor > all languages and turning on statement completion options (for some reason they were off previously for me).

    If you have Resharper installed (or a tool like it) that by default turns off the built-in VS intellisense (since it replaces it with its own). That might have been why it was off for you initially.

    Hope this helps,

    Scott

  • Session-less Controller, is there any explanation when and why we need it?

  • How to use the @section feature?

    I have this in my layout page:

    @RenderSection("CSSPageExt", required: false)

    ..and this in my view page:

    @section CCSPageExt {
    <link href="/Css/ ...
    }

    But I get an Exception:

    "The following sections have been defined but have not been rendered for the layout page"

    Furthermore, the editor highlights in green that <link .. can’t be nested …

  • Ok, so did something in the Razor syntax parser change? My app is breaking left and right after upgrading from MVC3 beta - it's throwing Razor parser errors all over the place on stuff that worked fine before my upgrade.

  • @Charles Ouellet

    I'm having the same problem, I'm getting an error saying that WebData doesn't exist in the WebMatrix namespace. This happens in an autogenerated file called App_Code.eo5s4zel.0.cs with a namespace called Helpers. Modifying this file didn't have any effect, as it autogenerates itself again.

    Help?

  • Will Razor Intellisense make it into WebMatrix?

  • I'm having some namespace issues as well (can't resolve System.Web.Helpers). I created a new mvc3 razor project and fired it up, and I'm getting compilation errors. Not sure if it's an issue with the release, or just a problem with the razor project template, but here it is....

    Compilation Error

    Compiler Error Message: CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

    Source Error:

    Line 19: using System.Web.Helpers;

    Source File: c:\Users\...\AppData\Local\Temp\Temporary ASP.NET Files\root\f5a3720d\b876c97f\App_Web_index.cshtml.a8d08dba.ejoz9vea.0.cs Line: 19

  • Thanks a lot for Razor!

    I write you about two bugs in Razor that I've found.
    I tested these bugs in this RC version, and they're not fixed yet.

    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 intFormatter = @- @item -;
    }

    That code translates to:

    public class _ViewStart_cshtml : System.Web.Mvc.ViewStartPage {
    ...
    public override void Execute() {
    Func 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 intFormatter = @- @item -;

    translator generates:

    WriteLiteralTo(@__razor_template_writer, "\t\t\t");
    WriteLiteralTo(@__razor_template_writer, "- ");
    ...

    so, it generates writes for whitespaces BEFORE @, from code context!

  • I fixed my issues by explicitly referencing the Webmatrix.Webdata.dll and Webmatrix.Data.dll files in C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies and setting Webdata.dll to CopyLocal=true

  • those who have namespace issues should seek the webpages beta3 framework available here :
    http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e750fc0b-8b8f-46f9-b30f-0ead6f6e538c

  • Any indication of a release date?

    And something not (too) related, are we going to see an intellisense file (.vsdoc) for jQuery v1.4.3? (the last one was for v1.4.1 back in Jan 2010)

  • Christian, I am having the same issue though a co-worker who installed the RC isn't. The only different we could find between our machines is I installed the Async CTP and Azure tools.

  • Thanks for this. I love the new labelfor(), however, there are some cases were we put a label just for accessibility. In those cases, we don't want it shown to the sighted, just read by a reader, so we have a css class to hide it (basically move it off the screen, but the reader can't see it).

    The problem is in the new labelfor() methods, there isn't an override to specify htmlAttributes like there are on others. I would like to see that.

  • @Guest,

    >>>>>> Session-less Controller, is there any explanation when and why we need it?

    The release notes cover this more (you can download them from the download link above). Session state is designed so that only one request from a particular user/session occurs at a time. So if you have a page that has multiple AJAX callbacks happening at once they will be processed in serial fashion on the server. Going session-less means that they would execute in parallel.

    Hope this helps,

    Scott

  • @itai,

    >>>>>>> How to use the @section feature?
    >>>>>>> I have this in my layout page: @RenderSection("CSSPageExt", required: false)
    >>>>>>> ..and this in my view page:
    >>>>>>> @section CCSPageExt {
    >>>>>>> >>>>>>
    >>>>>>> }

    >>>>>>> But I get an Exception:

    >>>>>>> "The following sections have been defined but have not been rendered for the layout page"

    >>>>>>> Furthermore, the editor highlights in green that <link .. can’t be nested …

    You have a typo in your code - the name of the section in the master doesn't match the name of the one in your page - CSSPageExt vs. CCSPageExt (note the first three characters are different).

    The green warning squigglie is expected in this case because you are using an element () that is only valid under the and the editor doesn't know where it will be rendered, so we assume it's in the tag. You can ignore this error though - it will not cause a problem at runtime.

    Hope this helps,

    Scott

  • @James,

    >>>>>> Ok, so did something in the Razor syntax parser change? My app is breaking left and right after upgrading from MVC3 beta - it's throwing Razor parser errors all over the place on stuff that worked fine before my upgrade.

    Did you customize your web.config file at all? Alternatively, are you sure you've uninstalled the old version of ASP.NET Web Pages (it was a separate install with the beta) prior to installing the MVC 3 RC?

    Thanks,

    Scott

  • @mikesdotnetting

    >>>>>> Will Razor Intellisense make it into WebMatrix?

    Eventually yes - but not for V1. With V1 of WebMatrix we'll support C#/VB colorization but not intellisense.

    Sorry!

    Scott

  • @Diego, @Charles Ouellet

    >>>>>>> I'm having the same problem, I'm getting an error saying that WebData doesn't exist in the WebMatrix namespace. This happens in an autogenerated file called App_Code.eo5s4zel.0.cs with a namespace called Helpers. Modifying this file didn't have any effect, as it autogenerates itself again.

    If you can send me email (scottgu@microsoft.com) I can connect you with someone on the team to help. I just saw a thread where they said there was a known issue in today's build with this, and that they might be able to suggest a workaround.

    Hope this helps,

    Scott

  • @Antoine,

    >>>>>>> using the rss feed on google home page for reading your lastest posts, but the widget remains stuck on this post and older ones :

    Sorry about that - I'm not sure why that happened. I'll try and follow-up - but am not sure I can fix it on my side. Google Reader does seem to be handling my posts fine - so it has something to do with the Google home-page.

    Hope this helps,

    Scott

  • Is there a way to programmatically invalidate the cache? There are cases where it would make sense to keep something in cache until, for example, an admin changes something. If we could assign a cache key of some kind and then be able to refresh / invalidate that cache key it would cover a lot of scenarios.

  • @Christian Sparre, @John Downey I have the same problem with "Unable to evaluate the expression." I had installed Async CTP. This problem mentioned in Release Notes, but I read about it after installing mvc3rc. Anybody known how to fix it?

  • Can you post info on the WebMatrix namespace issue? This seems to be happening on every computer I have installed MVC 3 on with projects that already existed (new projects work fine).

  • Great release! Now I can finally use Razor in my project. Been waiting a while for this. One thing I noticed though, is that there doesn't appear to be any design time checking or error highlighting on the view model. For example:

    View.Title = Model.SomeProperty;

    If my model doesn't contain a member called SomeProperty, the IDE doesn't tell me that until it throws a runtime error.

  • This is cool, although like others I have no intellisense :-(

  • Will the validation by localized out of the box ? That would be very nice !

  • Congrats.. looking forward to this release. big props to the team !

  • I worked out my intellisense problem. I had set HTML as the default editor for cshtml files. I had to Open With... and select Razor as the default editor.

  • I'm not seeing any difference with the primary\foreign keys. Can you explain that better?

  • Awesome news Guru-Gu and the ASP.NET team :)

    Not wanting to hijack this thread - but is the a *very rough* timeframe for VS2010 SP1? Will the new SqlServer CE 4.0 come in SP1?

    thanks mate!

  • Since mvc3 has a "go-live" license, can it be bin deployed to a shared hosting production environment with razor views? Which assemblies must be copied? Thanks in advance.

  • Started working seconds after I posted it wasnt working - sorry.

    Woop Woop MVC 3 is here though! - I love MVC

  • @Scott927, the Model property is Dynamic by default, so the editor won't provide IntelliSense or validate the properties. It will be a runtime check instead. If you hover your mouse over the Model property you should see a Quick Info tooltip telling you it's a dynamic expression.

  • @random guy,

    >>>>>>> I'm having some namespace issues as well (can't resolve System.Web.Helpers). I created a new mvc3 razor project and fired it up, and I'm getting compilation errors. Not sure if it's an issue with the release, or just a problem with the razor project template, but here it is....

    You shouldn't be seeing this. Did you have an earlier version of ASP.NET MVC 3 or WebMatrix installed on the machine? If so, did you remove it before installing the ASP.NET MVC 3 RC?

    Also - did you have the Async.NET CTP installed? I just learned that there is an issue with that and the ASP.NET MVC 3 RC on the same machine. You should uninstall that before installing ASP.NET MVC 3 RC to avoid problems. If you already installed both, you should uninstall both - and do so in the reverse order in which you installed them. This will get you back to a clean state. You can then choose which of the two you want to install and install that one again.

    Hope this helps,

    Scott

  • @Igorbek,

    Can you try posting this question in the MVC forum on http://forums.asp.net - that way someone from the team can connect directly and help answer.

    Thanks,

    Scott

  • Is there a list of all available Attributes in MVC and a short description of their use ?

    If not I think it would make it easier to get a good overview of the options available if there was one.
    Maybe group them into Categories like Model and Controller etc.


    Martin

  • @Nicolas,

    >>>>>>> Any indication of a release date?

    Pretty soon now - the final release is probably a few weeks away.

    >>>>>>> And something not (too) related, are we going to see an intellisense file (.vsdoc) for jQuery v1.4.3? (the last one was for v1.4.1 back in Jan 2010)

    Yes - I need to follow-up on this. I asked about this a few weeks ago but don't know the latest status. I will chase it up.

    Thanks,

    Scott

  • @John Downey,

    >>>>>>> Christian, I am having the same issue though a co-worker who installed the RC isn't. The only different we could find between our machines is I installed the Async CTP and Azure tools.

    I just learned that there is an issue with having both the Async.NET CTP and ASP.NET MVC 3 RC on the same machine. If you already installed both, you should uninstall both - and do so in the reverse order in which you installed them (meaning if you install Async before MVC, you should uninstall MVC first and then Async). This will get you back to a clean state. You can then choose which of the two you want to install and install that one again.

    Hope this helps,

    Scott

  • @pbz,

    >>>>>> Is there a way to programmatically invalidate the cache? There are cases where it would make sense to keep something in cache until, for example, an admin changes something. If we could assign a cache key of some kind and then be able to refresh / invalidate that cache key it would cover a lot of scenarios.

    There is - although I need to double check the exact cache key semantics we use to figure out how.

    Thanks,

    Scott

  • @mstyura

    >>>>>>>>>> @Christian Sparre, @John Downey I have the same problem with "Unable to evaluate the expression." I had installed Async CTP. This problem mentioned in Release Notes, but I read about it after installing mvc3rc. Anybody known how to fix it?

    I just learned that there is an issue with having both the Async.NET CTP and ASP.NET MVC 3 RC on the same machine. If you already installed both, you should uninstall both - and do so in the reverse order in which you installed them (meaning if you install Async before MVC, you should uninstall MVC first and then Async). This will get you back to a clean state. You can then choose which of the two you want to install and install that one again.

    Hope this helps,

    Scott

  • Will there be a new MVC Futures DLL with MVC 3... perhaps with some more REST goodness?

  • Did the default authentication mode change by any chance? On MVC 3 beta, I was able to comment out the whole authentication section in my web.config, and it would default to FormsAuthentication and loginUrl of "/Account/Login". On RC, it seems the default mode is now WindowsAuthentication, and if I change it to FormsAuthentication but don't specify a loginUrl, it defaults to "/login.aspx", which is kind of odd...

    Other than this, the Intellisense support for Razor is a pleasure to use, I couldn't be happier with this release. Big props for you guys. Keep up the great work, MVC is coming along wonderfully!

  • Did the default authentication mode change by any chance? On MVC 3 beta, I was able to comment out the whole authentication section in my web.config, and it would default to FormsAuthentication and loginUrl of "/Account/Login". On RC, it seems the default mode is now WindowsAuthentication, and if I change it to FormsAuthentication but don't specify a loginUrl, it defaults to "/login.aspx", which is kind of odd...

    Other than this, the Intellisense support for Razor is a pleasure to use, I couldn't be happier with this release. Big props for you guys. Keep up the great work, MVC is coming along wonderfully!

  • Traditional ASP.NET developer piao guo, going to learn ASP.NET MVC in future if my business requires it:)

  • Installation fails repeatedly on Win 7 64-bit. I dont even have the Asnyc.NET CTP installed

  • @Alex,

    >>>>>> Can you post info on the WebMatrix namespace issue? This seems to be happening on every computer I have installed MVC 3 on with projects that already existed (new projects work fine).

    Can you send me email (scottgu@microsoft.com) about this? I can then connect you with someone to help.

    Thanks,

    Scott

  • @Scott927,

    >>>>>>>> Great release! Now I can finally use Razor in my project. Been waiting a while for this. One thing I noticed though, is that there doesn't appear to be any design time checking or error highlighting on the view model. For example: View.Title = Model.SomeProperty; If my model doesn't contain a member called SomeProperty, the IDE doesn't tell me that until it throws a runtime error.

    The "View" property within Razor is a dynamic property that maps to the ViewData collection, which is why you aren't getting intellisense or compile-time checking (it is late-bound).

    The "Model" property within Razor is typically strongly-typed - which gives you compile-time checking and intellisense.

    Hope this helps,

    Scott

  • Seriously MS needs to slow down the release cycles just a tad.
    As soon as MVC3 is released (March 2011?) it will only be out in the wild for a year then there's a newer version to contest with in 2012. Why don't you have longer release cycles? With a longer release cycle maybe you can fit more features into each release rather than creating smaller and more frequent releases.

    Just like the iPhone, buy a new one today then it will be out of date come this time next year.

    How can anyone ever keep up!

  • Just curious, will we be able to return several views in one go in mvc3's next release?
    Mainly to solve the problems introduced by having to update several different areas of a web page, there are currently two solutions, 1): que the requests, and the user sees this queuing in action and the waiting incurred, 2): using really nasty JavaScript to split the response and place them under.different divs. This goes against everything mvc and web programming stands for.

    I hope it's solved for mvc3 - if several view returns (in one request) are supported I think so many other innovative use-cases would come out of this as well as solving the above problem :).

    Thanks. Also, what do other readers think?

  • Big thanks to the ASP.NET MVC team

  • @Craig,

    >>>>>> This is cool, although like others I have no intellisense :-(

    Can you go into tools > options > text editor > all languages and make sure intellisense is turned on. It could be that you have installed a utility like Resharper that might have disabled it. Send me email (scottgu@microsoft.com) if that doesn't work and we can help further.

    Thanks,

    Scott

  • @Eric,

    >>>>>>> Will the validation by localized out of the box ? That would be very nice !

    Yes - the nice thing about the validation architecture is that you can fully localize error messages and they'll work both on the server and with the client-side validation architecture.

    Hope this helps,

    Scott

  • @peaboy,

    >>>>>> I'm not seeing any difference with the primary\foreign keys. Can you explain that better?

    When you use the Add->View dialog now we are a little smarter about detecting primary keys. For example, with lists we now link to details/edit/delete actions with them, and with edit/create we are smarter about the editing fields.

    Hope this helps,

    Scott

  • @PK,

    >>>>>> Not wanting to hijack this thread - but is the a *very rough* timeframe for VS2010 SP1? Will the new SqlServer CE 4.0 come in SP1?

    ASP.NET MVC 3 will actually ship before VS 2010 SP1. VS 2010 SP1 will include tooling support for SQL CE and IIS Express though.

    Hope this helps,

    Scott

  • @Peter,

    >>>>>> Since mvc3 has a "go-live" license, can it be bin deployed to a shared hosting production environment with razor views? Which assemblies must be copied? Thanks in advance.

    Yes - I believe that is fully supported. I think you just need to copy-local the references in your project.

    Hope this helps,

    Scott

  • So is the Html.Action the same as the Html.RenderAction from the MvcFutures lib? Or are there differences? Partial OutputCache was already possible using Html.RenderAction, however, I'd be more excited about a way to use out-of-the-box 'donut hole' caching as described by Phil Haack. In other words, cache a whole page except for a small part. Is there a chacne we'll see this in MVC 3?

  • @Deepak Chawla,

    The release notes include pretty detailed upgrade instructions to go from V2 to V3. Definitely check those out.

    Hope this helps,

    Scott

  • @Piers,

    >>>>>>> Will there be a new MVC Futures DLL with MVC 3... perhaps with some more REST goodness?

    Yes - we'll have a MVC Futures DLL as as well with lots of goodies in it.

    Thanks,

    Scott

  • @Daniel,

    >>>>>>> Did the default authentication mode change by any chance? On MVC 3 beta, I was able to comment out the whole authentication section in my web.config, and it would default to FormsAuthentication and loginUrl of "/Account/Login". On RC, it seems the default mode is now WindowsAuthentication, and if I change it to FormsAuthentication but don't specify a loginUrl, it defaults to "/login.aspx", which is kind of odd... Other than this, the Intellisense support for Razor is a pleasure to use, I couldn't be happier with this release. Big props for you guys. Keep up the great work, MVC is coming along wonderfully!

    Sorry about that. With the beta we inadvertently picked up the WebMatrix authentication library. This has since been backed out of the RC. You should keep the authentication section in web.config to control the login URL now.

    Hope this helps,

    Scott

  • @Hakeem Mohammad,

    >>>>>>> Installation fails repeatedly on Win 7 64-bit. I dont even have the Asnyc.NET CTP installed

    If you can send me email (scottgu@microsoft.com) we can have someone investigate to figure out what is going wrong.

    Thanks,

    Scott

  • (continued from my first post...)... Just to be clear, the problem I described is an issue when making ajax requests from client and wanting to update several different areas/divs of a web page, say, one div on the top of the page and one on the bottom. You could of course return it in one update and return the two areas and everything in between, but this would just defeat the purpose of Ajax and having partials - I just wanted to clarify the problem I was describing better, I hope I have, thanks.

    Will this be happening for mvc3 at some stage?

  • one problem is performance is bad in mvc 3 razor RC,half the mvc 2 aspx

  • Hi Scott,

    with the new feed for nuget packages it is no longer possible to download packages onto my machine. when are you going to enable this again.

  • Hello!
    Scott, how to implement scenario when on one page I have several "models".
    For example:
    realty object
    table with several sellers of this object
    & table for each seller with phones of seller.

  • Simple question) Does this work in Visual Studio 2008 professional?
    The release note mention need .NET4 and VS 2010.

  • @ScottGu,

    >>>>> Can you try posting this question in the MVC forum on http://forums.asp.net - that way someone from the team can connect directly and help answer.

    I have already posted this issues at the forum: http://forums.asp.net/t/1618460.aspx?2+bugs+in+Razor+view+engine
    But no one from the MVC team answered.

    I also wrote to Andrew Nurse, and he said that first issue will be fixed to RTM, but the second will not. It may be fixed to Razor v2!

  • Hi,

    When can we expect a MVC Futures 3.0? Can I use the MVC Futures 2.0 RTM meanwhile?

    Thanks,
    Edmund

  • Hi Scott,

    I've come across one minor problem:
    When adding a strongly-typed view with a nested class as the view data class, the @model directive is incorrectly generated. A '+' is inserted before the nested part of the class name, where it should be a '.'

    Thanks
    Chris

  • Hi Scott,

    I notice the IDependencyResolver interface does not have a Release implementation that is required, how are the default factories going to release controllers from the container, or is it upto me to implement a new factory and do this myself again?


    Thanks

  • Since I've installed new MVC 3 and NuGet I'm not being able to install any package.
    I'm receiving the following message:

    PM> Install-Package SQLCE.EntityFramework
    Install-Package : Object reference not set to an instance of an object.
    At line:1 char:16
    + Install-Package <<<< SQLCE.EntityFramework
    + CategoryInfo : NotSpecified: (:) [Install-Package], NullReferenceException
    + FullyQualifiedErrorId : NuGet.VisualStudio.Cmdlets.InstallPackageCmdlet

    What is happening???

  • After working without intellisense for a couple months, I could not be happier with the improvements this RC offers. Unfortunately, I have also encountered the issue previously posted by "Random Guy".

    Compiler Error Message: CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

    I followed the steps in the release notes and thus believe all system references are correctly added to the project. Going through the standard troubleshooting steps, I uninstalled all previous versions of both MVC and MVC VS Tools. Then reinstalled MVC 3 RC. This to no avail, produced the same compilation error as before.

    Any help is greatly appreciated.

  • Hi,

    So glad the razor intellisense works. This was a showstopper for us. Razor is so much nicer than aspx.

    I've got a question/feature request about @section and @RenderSection though. With an asp:ContentPlaceHolder it was possible to provide default content in the masterpage which could be overridden in a viewpage. This doesn't seem to work with @RenderSection. A @section with the same name in the masterpage is simple ignored. I couldn't think of any other way to try. Is this already possible or will it be in the RTM?

  • GREAT!!! Love Razor...


  • I only have Visual Web Developer 2010 Express. Does it support Razor ? Since there is no viewengine option on the addview dialog. If yes, could anyone point me to how to use it ? Really appreciate.

    Scott

  • Wish you guys would put the same amount of energy into improving WebForms :)

  • Scott,

    After I installed MVC 3.0 RC the async bits stopped working. I have those bits installed before I installed MVC 3.0 RC. I tried to reinstall them but it didn't work. Do you have any idea of what is going on? Could you give me some directions?

    Thanks

  • How about SQL CE 4.0? Has that been updated or are we still at CTP1? SQL CE4 looks promising, but the lack of tooling makes it difficult to use - and the lack of information on updates makes it difficult to plan.

  • Scott,

    I'm confused about how to "share" declarative helpers in MVC 3 RC. What I thought we would be able to do is create a cshtml file somewhere with a declarative helper that can be accessed by all views. I tried putting them in /Views/Shared but that doesn't work. Or maybe I'm missing something in the cshtml file itself (the one that contains the helper to be shared)?

    Can you clarify?

  • I have Windows 7 64bit as well and the installation seems to be stuck at the start.
    The upper status bar is full and says:
    (above) File security verification:
    (below) All files were verified successfully.
    The lower status bar is at 0% and says:
    (above) Installation progress:
    (below) Installing VS10-KB2385361-x86

    It's been working for over an hour now and moved nowhere.
    Also the x86 bothers me a bit. Is there a x64 version?

    I had MVC3 Beta before this and MVC3 Preview 1 before that.

  • >>>>>>>> Great release! Now I can finally use Razor in my project. Been waiting a while for this. One thing I noticed though, is that there doesn't appear to be any design time checking or error highlighting on the view model. For example: View.Title = Model.SomeProperty; If my model doesn't contain a member called SomeProperty, the IDE doesn't tell me that until it throws a runtime error.

    >>>>The "View" property within Razor is a dynamic property that maps to the ViewData collection, which is why you aren't getting intellisense or compile-time checking (it is late-bound).

    >>>>The "Model" property within Razor is typically strongly-typed - which gives you compile-time checking and intellisense.

    Hey Scott,

    Sorry if I wasn't clear. I was simply assigning a value from the Model to the dynamic View property as an example. The problem I'm describing is isolated solely to the strongly-typed Model object. For example, using the following in my .cshtml file:

    @Model.Community.FormattedAddress

    Doesn't indicate any type of error at all, even though FormattedAddress is not a property of the Community object. Of course, it throws an error at runtime:

    Compiler Error Message: CS1061: 'Data.Community' does not contain a definition for 'FormattedAddress' and no extension method 'FormattedAddress' accepting a first argument of type 'Data.Community' could be found (are you missing a using directive or an assembly reference?)

  • Is it possible to implement the following overload for Html.Action method:

    @Html.Action(x => x.DailySpecials(Model.CategoryID))

  • Hmm, funny thing...

    As I said earlier I started the installation, but it still wasn't going nowhere after more than an hour.
    I got tired of waiting so I clicked cancel at which point the installation actually started progressing.
    After about 10 minutes MVC3 RC was installed.

    This is a bit weird but at least it's installed.

  • I can't seem to see it anywhere and I Imagen that there must be a syntax element for it... Non-renderable Razor comments? I'm at a loss as I tend to write a lot of comments both in code and otherwise whilst im writing pages.

    Could you help please scott - probably a tad easy to answer for someone that knows...

  • Scott -- Any chance there is a problem with the Html.EndForm() method in this release?

    I can't get it to work for the life of me. I get the following error anytime I add it to any page, even on a brand new project.

    CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments


    Same error with Razor and the previous view engine.

  • Hi Scott,

    Looks like the RC still doesn't patch Visual Studio to include .cshtml and .vbhtml files in the Publish service. (Note that this happens both in the Web Deploy / MSDeploy scenario as well as with a local File System publish.)

    I also didn't see a reference to this issue in the MVC3 RC release notes.

    Is publish support on the roadmap for RTW?

  • Hey Scott, any chance we'll see a return of support for post-cache substitution? Allowing both partial output caching and post-cache substitution would offer great flexibility in complex caching situations.

  • Quoting myself:
    "Scott,

    After I installed MVC 3.0 RC the async bits stopped working. I have those bits installed before I installed MVC 3.0 RC. I tried to reinstall them but it didn't work. Do you have any idea of what is going on? Could you give me some directions?"

    I found the answer for that in the release notes doc. The question would be then: the final (or upcoming) version of MVC 3.0 will be compatible with async bits?

    Thanks

  • I'm also having the "system.web.helpers" issue after installing the RC. I did have the preview 1 previously installed, and installed overtop of it, which is probably causing the issue. Since then I've uninstalled both and then reinstalled the RC, but that hasn't solved the issue.

    PS> Congrats Scott! Dedication == posting while on parental leave :)

  • @pwills

    Publishing should work correctly with .cshtml and .vbhtml files. Can you pls send me the details of the problem you're having at dedward@microsoft.com so we can look into it for you.

    Thanks.

  • Razor works in Visual Web Developer 2010 Express, but only in new-created MVC 3 projects. Looks great !

    Scott

  • Says fileis corrupt? will not extract

  • Getting an extract error on the exe

  • It appears that any additional (custom) assemblies - such as adding your own view helpers as extension methods in a dll - that are referenced in the main web.config file have to also be referenced in the web.config file for the views. I don't think this is correct as it seems to be opposed to the DRY principle.

  • The following appears to be broke in MVC 3. Posts that worked ok in MVC 2 now produce the "dangerous" message error:

  • Exciting. My next hobby project is going in this bad boy, and I'll try Razor to boot. Thanks!

  • I want to make statues for every member of the MVC team for the JSON binding built into MVC 3.0. Seriously. If I could send medals over the internet, I would.

  • @ChuckKraatz

    If your having coruption errors it might be the IE9 beta. I tried with a different browser and the download worked fine after that.

  • Hi Scott,

    I'm running into an issue with the ReCaptcha web-helper after upgrading to MVC3 RC from Preview.

    The error is:
    Attempt by method 'Microsoft.Web.Helpers.ReCaptcha.GetHtmlWithOptions(System.String, System.Object)' to access method 'System.Web.WebPages.WebPageContext.get_HttpContext()' failed.

    Any thoughts?

  • @Random Guy

    Verify that these two lines exist in your web.config assemblies section.


  • Thanks for the info, great article.

  • Hi Scott! I'm always getting an "Unable to evaluate expression." error in debug mode after installing the MVC 3 RC.
    Some others are having the same problem:

    http://connect.microsoft.com/VisualStudio/feedback/details/571011/cannot-evaluate-immediate-expressions-using-vs2010-professional-under-framework-3-5

  • Yes indeed. I also have an issue with "using System.Web.Helpers;" in some temp file App_Web_index.cshtml. Refference is missing and there is no library left but something still points to it. I uninstalled all previous versions of MVC, never had Async CTP and no line with "add assembly="System.Web.Helpers". Any solutions? Thanks.

  • Awesome stuff. Any update on reusable declarative helpers? - Same question as Johann >>>


    Scott,

    I'm confused about how to "share" declarative helpers in MVC 3 RC. What I thought we would be able to do is create a cshtml file somewhere with a declarative helper that can be accessed by all views. I tried putting them in /Views/Shared but that doesn't work. Or maybe I'm missing something in the cshtml file itself (the one that contains the helper to be shared)?

    Can you clarify?

  • [SkipRequestValidation] is an awful name -- there are so many different kinds of request validation, and that name doesn't specify which one it means. Why didn't you name it for what it does -- something like [AllowHtmlContent]?

  • Nice article on MVC 3 i got many questions answered by reading this article. Thanks.

  • After upgrading from the ASP.net MVC 3 Beta, I'm getting the following error on publishing to our dev server:

    [MissingMethodException: Method not found: 'System.Nullable`1 Microsoft.Web.Infrastructure.DynamicValidationHelper.ValidationUtility.IsValidationEnabled(System.Web.HttpContext)'.]
    System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +0
    System.Web.Mvc.c__DisplayClass6.b__2() +71
    System.Web.Mvc.c__DisplayClassb`1.b__a() +19
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +161
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +389
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371

    Any ideas?

  • Congrats Scott! I'll try out later. Cheers!

  • Love the new declarative helpers. Will we be able to use generic type parameters in RTM? For example:

    @helper SomeFunc(IEnumerable items) { }

    Right now this produces syntax errors.

    It would be great to see generic constraints, as well.

    Either way, Razor is clearly more productive than ASPX. Can't wait to get into it further.

  • what a paint this install has been:
    -install mvc3 rc - fails to install, errors.
    -reboot - re-run installer- succeeds now. but, launching vs2010 crashes out.
    -reboot- now vs2010 will actually launch. but, cshtml files do not have intellisense.

    What else will i encounter just trying to get this running?

  • I noticed you ship a dll System.web.webpages.administration.dll with the webpages package. I reall wonder what that's for, but even more... I wonder how you managed to get those compiled cshtml pages in there?

    Surely it could be done with aspnet_compiler and then add those cs files manually and add the PageVirtualPathAttribute by hand also, but I'm sure you guys have some tool that automates this ?

  • I think at least with VWD best solution to start use RC is start a new MVC3 project and copy files from old project. It took me about an hour but I think it worth it. As far as I have seen looks really cool. Congrats to all MVC team!

  • I seem to be missing the CompareAttribute. The type or namespace cannot be found...
    Anyone else?

    Great work btw, thoroughly enjoying MVC.

  • The LabelExtensions appear to be using the TemplateInfo.GetFullHtmlFieldName for the "for" attribute:

    System.Web.Mvc.Html.LabelExtensions.LabelHelper
    tagBuilder.Attributes.Add("for", html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName));

    Should it not be using TemplateInfo.GetFullHtmlFieldId?

  • I'm not getting intellisense on the package manager console. What am I doing wrong?

  • Thanks for a great release, I'm loving the new Razor engine!

    I think I found an issue with OutputCache on partial views.
    I'm calling my child action via @Html.Action and set this attribute on the action:
    [OutputCache(Duration = 1200, VaryByParam = "groupId")]

    However, my URL has a custom route ("/View/1" where 1 is mapped to parameter "groupId"), and it seems the child action is ignoring the routes when called via this way.
    If I change the URL from /View/1 to /View?groupId=1 then it works.

    I hope this gets fixed before RTM, but so far it's the only issue I've found!

  • It took a while installing on my Win 7 machine. Hitting F5 after creating a small app doesnt do anything though. I have FF as my default browser so I thought that might be an issue and made IE the default. still no dice.

    Also when the app is published and run, it is not recognizing the targetFramework attribute. This hasn't been an issue with other MVC versions or the beta of MVC3. And, oh the cshtml files aren't getting published either, as someone already posted earlier

    Thanks!

  • I found a way from web to reuse @helper:

    1. create an App_Code directory, and put the some.cshtml with @youHelper in it.

    2. define two dummy classes in your project:
    namespace WebMatrix.Data { public class Foo {} }
    namespace WebMatrix.WebData { public class Foo {} }

    3. reuse the helpers by @some.yourHelper in razor views.

    4. compile and run it.

    Scott L.G.

  • Loving this new release! A big step forward! Keep up the good work guys.

  • ASP.NET MVC3是否能提供通过URL获取OutputCache的Key名称?

  • I can't seem to get sections working from a partial layout.

    _Layout.cshtml:
    @RenderSection("CssPageExt", required: false)

    Form.cshtml
    @Html.Partial("Panel");

    Panel.cshtml
    @* no error-message, but doesn't do anything *@
    @section CssPageExt {

    }

    When placing the @section code in Form.cshtml it works perfectly.

  • In the video, ScottHa shows how you can open the generated .sdf file in Visual Studio. I'm getting the following error when I try.

    This is not a valid SQL Server Compact Database file or this file version is not supported by current SQL Server Compact Engine.

  • We have been using the MVC3 bits for a while and it's amazing... awesome work.

    I have run into a related issue with the MVC3 bits (both P1 and RC) and the Azure bits. When I take an Azure project and attempt to add an MVC2 web role to it, I get the new project dialog asking me if I want to use Razor as the view engine. Then no matter what options I select in that dialog (Razor/ASPX, empty or sample project with/without tests), I get a studio error "Cannot add the item because the item to add is not a solution folder or the solution". It appears to be a generic studio error about placement of files within the solution and I would guess it's related to the new project template but have yet to issolate the specific issue.

  • Got a "Microsoft Visual Studio has stopped working..." What to do?

  • @JoeReynolds,

    >>>>>>> The following appears to be broke in MVC 3. Posts that worked ok in MVC 2 now produce the "dangerous" message error:


    We think we just checked in a fix for this issue. If you could send me email (scottgu@microsoft.com), though, we'd love to verify the issue with you to make sure we fixed the exact issue you ran into.

    Thanks,

    Scott

  • when will the compatible futures dll be released? its still not there...

  • Scott,

    Is there a way to remove assemblies from being considered as part of the "strongly-typed" list when you add a new view. When I try and add a strongly-typed view through the dialog, I get thousands of classes which we would never be used, and some are not possible (as they are static classes).

    I am also not seeing any classes from inside by project. Since I am using ViewModels (in the solution) to wrap the models (which can't be made to work correctly for MVC), I need to see the classes within my project.

  • I can not seem to get the intellisense to work in the following scenerio...

    @{
    Layout = null;
    Mvc3App.Models.JDE_Employee EmpToOutput = (Mvc3App.Models.JDE_Employee)ViewData["Person"];
    }





    Index



    @ViewData["name"] is my name




    Your name is @(EmpToOutput.name)



    your title is @(EmpToOutput.title)



    your title is @(EmpToOutput.INTELLISENSE DOES NOT WORK HERE)


  • Hi Scott,

    You have mentioned that "Declarative HTML Helpers" will work if we add them in Helpers\View folder. But its not working.

    Would someone please update blog and point us to correct direction?

    Thanks,
    Sachin

  • Does TextBoxFor output a MaxLength attribute based on Data Annotation attributes yet?

  • Hi Scott,

    Is it correct that ASP.NET MVC 3 Release Candidate is not supported on Windows XP. Unfortunately this is the operating system we have to use at work and I imagine quite a few developers are in the same situation.

    Cheers,

    Lee

  • Hey Scott,

    I think I may have a similar issue to Sigurdur G. Gunnarsson with OutputCache on partial views.

    I'm calling my child action via @Html.Action and set this attribute on the action as follows:

    [ChildActionOnly]
    [OutputCache(Duration = 10, VaryByParam = "options")]
    public ActionResult GetSomething(MyTestOptions options)
    ...

    Where MyTestOptions is:

    public class MyTestOptions
    {
    public int SomeType { get; set; }
    public int SomeOtherValue { get; set; }
    }

    And I am calling this from a Razor template:

    @Html.Action("GetSomething", "Home", new { options = new MyTestOptions{ SomeType = 1, SomeOtherValue = 2 } })

    This all works well and is cached for the specified period, however, if I have an additional call to @Html.Action but provide different values for MyTestOptions I get the cached fragment from the first call. I get this behaviour if included in the same or different template e.g. Index.cshtml or About.cshtml.

    Regards,

    Paul

  • Another one here for Output caching with vary by param not working. I always get the first cached element, and it never varies from then on. This one would be great to see fixed!

    Additionally, it would be great to have a way of specifying this at runtime - rather than a compile time constant. E.g. if in production mode, cache for 60 minutes, if development, don't cache. Attributes only is rather limiting in terms of being able to dynamically adjust things - an alternative syntax or configuration would be very useful.

  • Hi Scott.

    Thanks for all the effort you and your team put into Asp.Net Mvc 3. Pretty great stuff.

    But what about the source code. Will it be opened to the public any time soon?

    Cheers.

  • Guys, I always got fatal error during the installation.

  • I have come across a situation that I want to write an "@" to my output (like the twitter @screenName) using the razor view engine :

    @username

    I'm getting the following error when i try this.
    Parser Error Message: "<" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.

    Is this a bug, or should i use some special construct?

    Regards,
    avsomeren

  • @Otyce,

    >>>>>>> with the new feed for nuget packages it is no longer possible to download packages onto my machine. when are you going to enable this again.

    Are you still having this problem? If so please send me email (scottgu@microsoft.com) and we can help.

    Thanks,

    Scott

  • @Paco,

    >>>>>>> Scott, how to implement scenario when on one page I have several "models".

    You can do one of two things:

    1) Pass a ViewModel object as the model of the page that has all of the model objects you require.

    2) Use Html.Action and implement the page using multiple controllers and separate views. The main view would then call out to the Sub-controllers using this approach. One nice thing with MVC3 is that you can now outputcache these separate sections.

    Hope this helps,

    Scott

  • @Deepak,

    >>>>>>>> Simple question) Does this work in Visual Studio 2008 professional?

    Yes - MVC3 requires either VS 2010 or Visual Web Developer 2010 Express. It uses features that are only supported with .NET 4.

    Hope this helps,

    Scott

  • @Edmund,

    >>>>>>> When can we expect a MVC Futures 3.0? Can I use the MVC Futures 2.0 RTM meanwhile?

    I believe MVC Futures 2.0 will work with it (but am not 100% sure). We'll have a MVC 3.0 Futures package available by the time MVC 3 ships.

    Hope this helps,

    Scott

  • @Chris,

    >>>>>> When adding a strongly-typed view with a nested class as the view data class, the @model directive is incorrectly generated. A '+' is inserted before the nested part of the class name, where it should be a '.'

    Thanks for reporting this. Can you send me email (scottgu@microsoft.com) with the use-case for this? The team has looked at fixing it, but wasn't sure if the fix was going to be riskier than it was worth (given that doing nested classes seemed rare). Can you send me more details on why you are using nested classes to make sure we understand the scenario better?

    Thanks,

    Scott

  • @AndreVianna

    >>>>>> Since I've installed new MVC 3 and NuGet I'm not being able to install any package. I'm receiving the following message: PM> Install-Package SQLCE.EntityFramework

    I believe this is caused because you have an older version of Refactor installed. Can you confirm if you have that installed?

    Thanks,

    Scott

  • @Anthony Capone

    >>>>>> After working without intellisense for a couple months, I could not be happier with the improvements this RC offers. Unfortunately, I have also encountered the issue previously posted by "Random Guy".

    Are you still running into this? If so, can you send me email (scottgu@microsoft.com)?

    Thanks,

    Scott

  • @ScottLG

    >>>>>>> I only have Visual Web Developer 2010 Express. Does it support Razor ? Since there is no viewengine option on the addview dialog. If yes, could anyone point me to how to use it ? Really appreciate.

    Yes - this should work fine with Razor. Do you have MVC3 RC installed?

    Thanks,

    Scott

  • @Jack,

    >>>>>>> I've got a question/feature request about @section and @RenderSection though. With an asp:ContentPlaceHolder it was possible to provide default content in the masterpage which could be overridden in a viewpage. This doesn't seem to work with @RenderSection. A @section with the same name in the masterpage is simple ignored. I couldn't think of any other way to try. Is this already possible or will it be in the RTM?

    Yes - you can do the same with Razor. I unfortunately don't have a pointer to a sample handy - but if you ask this question in the MVC forum on www.asp.net someone can point you to a sample.

    Hope this helps!

    Scott

  • @Jacob,

    >>>>>> Wish you guys would put the same amount of energy into improving WebForms :)

    Don't worry - we have a lot of investments going on with WebForms too. WebForms has been around a lot longer and has more features, which is why it feels like MVC is moving fast (it started from zero ).

    Hope this helps,

    Scott

  • @Asbjørn

    >>>>>>>> How about SQL CE 4.0? Has that been updated or are we still at CTP1? SQL CE4 looks promising, but the lack of tooling makes it difficult to use - and the lack of information on updates makes it difficult to plan.

    You'll see VS 2010 tooling support come for SQL CE 4.0 shortly. Stay tuned for details!

    Thanks,

    Scott

  • @Johann,

    >>>>>>> I'm confused about how to "share" declarative helpers in MVC 3 RC. What I thought we would be able to do is create a cshtml file somewhere with a declarative helper that can be accessed by all views. I tried putting them in /Views/Shared but that doesn't work. Or maybe I'm missing something in the cshtml file itself (the one that contains the helper to be shared)?

    We are working on this right now - it is a little harder to-do right now in a MVC app than we'd like (especially due to some issues we introduced with the RC). We'll share more details on how best to do this for the RTM.

    Thanks,

    Scott

  • @gligoran

    >>>>>>> I have Windows 7 64bit as well and the installation seems to be stuck at the start.

    Can you send me email (scottgu@microsoft.com) if you are still having problems with this?

    Thanks,

    Scott

  • @avsomeren

    >>>>>>> I have come across a situation that I want to write an "@" to my output (like the twitter @screenName) using the razor view engine : @username I'm getting the following error when i try this.

    The easiest way to escape the "@" character would be to write it like so:

    @@@username

    The double @@ tells the parser to treat it like a content character.

    Hope this helps,

    Scott

  • @scott

    Thanks for the clarification, could have come up with that myself.

    Keep up the good work on these awesome developments that will make our life better ;)

  • Can you add an option in route to make all urls lowercase?

  • Scott,

    Thanks for your reply. I can access Razor features by creating new MVC 3 projects.

    Saw the Razor Single File Generator solution to reuse @helper. Curious what will be in the final version : reuse @helper declarations inline, or reuse generated method calls ?

    Also any guide for the integration of MVC and MEF or Unity ?

    Really appreaciate your efforts.

    Scott L.G.

  • This is great! I'm looking forward to starting a project with MVC 3. I am running on 2008 R2 and the first time I tried to install it hung like someone previously described. I stopped the install and it was still hung on rollback. I used task mgr to kill it. I had to delete the files in c:\temp.

    When I ran this a 2nd time, it installed as I would expect.

  • How do we make ViewModel strongly typed? I hope there's new syntax '@view' to define the type.

  • Stacey made a comment on Phil Haack's blog, but didn't get any answer to this question:

    Inheriting Javascript Intellisense
    When I create a master page/layout page and put in javascript libraries, while the compile time works in inherited pages, the intellisense does not. If I reference jQuery-1.4.3 in my layout page, then create a new View, and start typing out some javascript, it it is not 'aware' of the reference to jQuery (whereas on the layout page, it is, and would give me full intellisense of the functions in jQuery (or any other .js file references). (This has actually been true in ASP.NET WebForms, so I think it is more of a Visual Studio issue than an MVC issue)

    I have the same problem and been searching for hours to find out how I can get intellisense to work in my views.

  • @AlexW,

    >>>>>> Can you add an option in route to make all urls lowercase?

    Yes - you can add a "constraint" to any MVC route that enforces certain behavior. You could do one, for example, that always makes the URLs lower-case.

    I'd also recommend checking out this post: http://weblogs.asp.net/scottgu/archive/2010/04/20/tip-trick-fix-common-seo-problems-using-the-url-rewrite-extension.aspx In it I cover how to setup URL routing rules that enforce lower-case URLs and can help improve SEO in general.

    Hope this helps,

    Scott

  • @Feng,

    >>>>>>> How do we make ViewModel strongly typed? I hope there's new syntax '@view' to define the type.

    The ViewModel property (which we are renaming for the final release to make it clearer) is actually a dynamic object - and should be thought of as a late-bound bag of additional stuff you pass to the View. This avoids you having to always define a strongly typed ViewModel that you pass as the Model of the View.

    If you want to always make the data you pass to a View strongly-typed, then I'd recommend creating a custom ViewModel class and then pass it as the model to the View. You can use the existing @model syntax to type it and get intellisense/compilation checking.

    Hope this helps,

    Scott

  • I created Internet project with unit tests. After that I run unit tests.
    All created tests were failed with same message "System.Security.VerificationException: Operation could destabilize the runtime."
    Thanks

  • @Stialy,

    >>>>>>>> I created Internet project with unit tests. After that I run unit tests. All created tests were failed with same message "System.Security.VerificationException: Operation could destabilize the runtime."

    Can you send me email (scottgu@microsoft.com) with more details of this? We'd like to investigate to understand it more.

    Thanks,

    Scott

  • Dear Scott ,

    Here is the situation .. we hav windows xp based production system .. what i want to ask is will MVC 3 would work on Windows xp ?? or specifically we need windows vista or later to work on visual studio and MVC 3 RC to work on ???

    as we hav only windows xp for the time being as production just wanna know if there are any ways we can work it around on with Windows XP and Visual studio 2010 ... specifically Windows XP is my query ..

    Thanks
    Joy

  • One control that i am really waiting for is the crystal report viewer so that we can avoid mixing asp.net webforms in mvc application

  • Two Questions:

    1)Has a final release date been communicated?

    2)Are there any issues with running MVC3 on IIS6?

  • I'm using a hosting service that has a dll of MVC3 Beta in their GAC, and it appears that even though I'm deploying the MVC3 RC dll to the bin folder, the Beta dll is taking precedence and my web application isn't compiling (eg the parameters to GlobalFilterCollection.Add are different in the RC compared to the Beta). Is there some solution to this problem that doesn't required the hosting service to take down the MVC3 Beta dll?

  • The MVC3 Release Candidate installs and works fine on Windows XP SP3, based on my personal quick test. There might be disappointments waiting around the corner but the MVC3-based simple solution builds and runs in Internet Explorer.

    I too was very nervous about not finding Windows XP in the list of system requirements for MVC3 Release Candidate. I hope it was helpful.

  • I nutted out MVC3 tonight, converting my own site from 2 to 3.
    But when I asked my host if this is supported yet (and these guys are good) I got the following answers:
    "We'll install this once stable edition is out since it had some weird results in our test environment and we were advised to wait till its stable release to obtain support related to it. "
    Then, in response to my question of which version they tried things out:
    "It was in fact RTM version that we used on a cloned web server and had pretty drastic results which broke existing MVC 2 apps as well. We were then advised to wait for stable version to obtain any kind of help/support from Microsoft for this.."
    Any comment on this? Krok is not happy.

  • HELP - All for C# error from "The Complete Reference - Herbert Schildt" Error - Unsafe code may only appear if compiling with /unsafe

    Errors from The Complete Reference errors pg. 608 - UnsafeCode, pg. 609 - FixedCode, pg.610 PtrArithDemo, 612 - PtrIndexDemo

    Sample - One of error and more
    using System;

    class _611_PtrArray
    {
    class Program
    {
    unsafe static void Main()
    {
    int[] nums = new int[10];
    fixed (int* p = &nums[0], p2 = nums)
    {
    if (p == p2)
    Console.WriteLine("p and p2 point to same address.");
    }
    }
    }
    }

    Error 1 Unsafe code may only appear if compiling with /unsafe

  • Chops (Friday, November 12, 2010 3:40 PM by Chops) is right: the "for" attribute of a label should match the "id" of an input. If not, clicking on a checkbox's label will not toggle the checkbox.

    The code in the Beta is correct though. See ASP.NET MVC 3 Beta Source Code\mvc3\src\SystemWebMvc\Mvc\Html\LabelExtensions.cs:
    tag.Attributes.Add("for", html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName));

    So it look like s a bug introduced in the RC.

  • @krokonoster

    >>>>>> I nutted out MVC3 tonight, converting my own site from 2 to 3. But when I asked my host if this is supported yet (and these guys are good) I got the following answers: "We'll install this once stable edition is out since it had some weird results in our test environment and we were advised to wait till its stable release to obtain support related to it. "

    As long as your host is running .NET 4 then you don't need them to install anything. Just mark the references in your project as "copy to local", and then all of the ASP.NET pieces necessary to deploy ASP.NET MVC 3 will be copied as part of the \bin directory of your app and work without anything extra needing to be installed.

    Send me email (scottgu@microsoft.com) if you run into any problems with this and I can help.

    Thanks,

    Scott

  • I downloaded the mvc3 rc, the setup hangs on "Installing VS10-KB2465236-x86", I thought it was because of the windows update that I haven't applied, so I did but it still hangs. I did install it fine on my home computer yesterday. This fails on my work laptop. I'm running win7 ultimate x64. Help?

  • Overall the new features in MVC 3 look great. However, I have noticed a small problem when using an if() block inside some jQuery script. In the following code, $("#navigationColumn").hide(); is syntax colored as if it is C# code rather than markup/JavaScript:

    $(function () {
    @if (!((BaseModel)Model).IsAuthenticated) {
    $("#navigationColumn").hide();
    }
    }

  • Nice One.... Good Work.

  • Finally partial output caching! i was waiting for it from version 1.

  • Thanks for the release.

    When is the RTM release?

Comments have been disabled for this content.