Introduction To New Release Candidates For MVC 5.1 and Web API 2.1

Introduction

Microsoft delivered the release candidates for ASP.NET MVC 5.1, ASP.NET Web Pages 3.1 and Web API 2.1 to the NuGet Packages Gallery in early December. There are various updates available for features previewed in ASP.NET and Web Tools 2013.2 like ASP.NET SignalR, ASP.NET Identity, Entity Framework and the Microsoft OWIN and you can also get the updates for the Web Editors, Browser Link, Scaffolding, NuGet and Windows Azure WebSite Publishing. Microsoft will be previewing all of these features along the way before all of the features are released.

Get this release

You can easily get the release candidates for ASP.NET MVC 5.1, Web Pages 3.1 and Web API 2.1 from the NuGet Packages Gallery. If you want to install these pre-release packages, then you can get these from Package Manager Console by using the following commands:

  • Install-Pacakage Microsoft.AspNet.Mvc - Version 5.1.0-rc1 -Pre
  • Install-Pacakage Microsoft.AspNet.WebApi - Version 5.1.0-rc1 -Pre
  • Install-Pacakage Microsoft.AspNet.WebPages - Version 3.1.0-rc1 -Pre 

You need to select the "Include Prerelease" option when you search for these packages in the NuGet Package Manager or the Package Manager Console.

Prerequisites

For using the release candidates, please install the Visual Studio updates as following:

After download, install the package. I download the Visual Studio 2013 Update 1 RC for Visual Studio 2013.

Installing Update 1 RC

Brief

Let's determine what are the new features included in this release candidates.

ASP.NET MVC 5.1

The following are the enhancements in this release.

Attribute Routing

The Attribute Routing will now support the constraints, versioning enabled and header based route section. Many aspects of attribute routes are now customizable via the IDirectRouteProvider interface and RouteProviderAttribute class.

Enum Support in Views

Now in ASP.NET MVC 5.1, the Enum type will be supported in Views. The new HTML Helper Html.EnumDropDownListFor() added will generate a dropdown when binding to Enum types. For this you need to declare an Enum as follows:

public enum StudentGrade

{

    A, B, C, D

}

public class Enrollment

{

    public int EnrollmentID { get; set; }

    public int CourseID { get; set; }

    public int StudentID { get; set; }

    public StudentGrade? Grade { get; set; }

    public virtual Course Course { get; set; }

    public virtual Student Student { get; set; }

}

Support of Bootstrap in Views

Now, you can pass in HTML attributes in Html.EditFor as an anonymous object. We can pass the various styles of Bootstrap in HtmlHelpers and customize the input elements like textboxes, dropdownlist and so on.

ASP.NET Web API 2.1

The following are the enhancements in this release.

Global Error Handling

In ASP.NET Web API, there is a centralized way to log all unhandled exceptions. There are also Logging Frameworks available like ELMAH that we can use to log all exceptions from the Web API to ELMAH.

Attribute Routing

The Attribute Routing will now support the constraints and versioning enabled and header based route section. Many aspects of attribute routes are now customizable via the IDirectRouteProvider interface and RouteProviderAttribute class.

IgnoreRoute Support

Now the Web API Routing support the URL ignoring patterns via a set of IgnoreRoute extension methods on HttpRouteCollection. This will cause any URLs matching the given template to be ignored by Web API.

BSON Media Type Formatter

Now the BSON wire format is supported on both client and sever assemblies.

Support for Async filters

Now it is easy to author async filters in the Web API. If you want to get a database or do some async work in the filter, you can now override the new virtual On*Async methods. AuthorizationFilterAttribute, ActionFilterAttribute and ExceptionFilterAttribute all support async now.

Query Parsing Support in Client Formatting

Now the query parsing and query update will be supported by System.Net.Http.Formatting. The client app can easily parse and update the query string in 5.1.

Improved Help Page

The Help Page feature in ASP.NET API is now enhanced so that the page can provide the extra information like:

  • Documentation of individual properties of parameters or return types of actions.
  • Documentation of data model annotations.
  • User Interface design change to accommodate the preceding changes.

Summary

This article has introduced the release candidates for MVC 5.1, Web API 2.1 and Web Pages 3.1 that are now available. You can also see the various enhancements made in these features used in Visual Studio 2012 and Visual Studio 2013. Thanks for reading.

Up Next
    Ebook Download
    View all
    Learn
    View all