Tutorials Forums
     Tutorials Videos
        Sign Up Now For FREE
09
November
2010

ASP.NET MVC 3 Release Candidate
4.4/5 rating (5 votes)

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

download-now 

 

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

image1

 

We also provide intellisense for Razor keywords and directives:

image3

 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:

image4

 

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:

image5

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:

image6

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.

image7

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:

image8

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:

image9

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.

System Requirements


  • Supported Operating Systems:Windows 7;Windows Server 2003;Windows Server 2008;Windows Server 2008 R2;Windows Vista
.NET 4, ASP.NET 4, Visual Studio 2010 or Visual Web Developer 2010 are required to use certain parts of this feature.
---------------
ScottGu's 

Ghasem Karimi

My name is Ghasem Karimi,  currently living and working in Sweden.
I have BSc. degree in Computer Sciences from the Iran University. Currently doing my Master thesis in the field of Computer Sciences where I am using .NET technologies for the master thesis project.
I can consider myself as a passionate .NET Developer, especially interested in web technologies such as ASP.NET (WebForms / MVC), ASP.NET AJAX, C#,WPF,WCF, JQuery, XML, Web Services, MS SQL etc.

Comments (0)

Leave a comment

Please login to leave a comment. Optional login below.