Microsoft ASP.NET MVC Changelog

What's new in Microsoft ASP.NET MVC 4.0

Apr 3, 2013
  • ASP.NET Web API:
  • ASP.NET MVC 4 includes ASP.NET Web API, a new framework for creating HTTP services that can reach a broad range of clients including browsers and mobile devices. ASP.NET Web API is also an ideal platform for building RESTful services.
  • ASP.NET Web API includes support for the following features:
  • Modern HTTP programming model: Directly access and manipulate HTTP requests and responses in your Web APIs using a new, strongly typed HTTP object model. The same programming model and HTTP pipeline is symmetrically available on the client through the new HttpClient type.
  • Full support for routes: ASP.NET Web API supports the full set of route capabilities of ASP.NET Routing, including route parameters and constraints. Additionally, use simple conventions to map actions to HTTP methods.
  • Content negotiation: The client and server can work together to determine the right format for data being returned from a web API. ASP.NET Web API provides default support for XML, JSON, and Form URL-encoded formats and you can extend this support by adding your own formatters, or even replace the default content negotiation strategy.
  • Model binding and validation: Model binders provide an easy way to extract data from various parts of an HTTP request and convert those message parts into .NET objects which can be used by the Web API actions. Validation is also performed on action parameters based on data annotations.
  • Filters: ASP.NET Web API supports filters including well-known filters such as the [Authorize] attribute. You can author and plug in your own filters for actions, authorization and exception handling.
  • Query composition: Use the [Queryable] filter attribute on an action that returns IQueryable to enable support for querying your web API via the OData query conventions.
  • Improved testability: Rather than setting HTTP details in static context objects, web API actions work with instances of HttpRequestMessage and HttpResponseMessage. Create a unit test project along with your Web API project to get started quickly writing unit tests for your Web API functionality.
  • Code-based configuration: ASP.NET Web API configuration is accomplished solely through code, leaving your config files clean. Use the provide service locator pattern to configure extensibility points.
  • Improved support for Inversion of Control (IoC) containers: ASP.NET Web API provides great support for IoC containers through an improved dependency resolver abstraction
  • Self-host: Web APIs can be hosted in your own process in addition to IIS while still using the full power of routes and other features of Web API.
  • Create custom help and test pages: You now can easily build custom help and test pages for your web APIs by using the new IApiExplorer service to get a complete runtime description of your web APIs.
  • Monitoring and diagnostics: ASP.NET Web API now provides light weight tracing infrastructure that makes it easy to integrate with existing logging solutions such as System.Diagnostics, ETW and third party logging frameworks. You can enable tracing by providing an ITraceWriter implementation and adding it to your web API configuration.
  • Link generation: Use the ASP.NET Web API UrlHelper to generate links to related resources in the same application.
  • Web API project template: Select the new Web API project form the New MVC 4 Project wizard to quickly get up and running with ASP.NET Web API.
  • Scaffolding: Use the Add Controller dialog to quickly scaffold a web API controller based on an Entity Framework based model type.
  • Enhancements to Default Project Templates:
  • The template that is used to create new ASP.NET MVC 4 projects has been updated to create a more modern-looking website
  • In addition to cosmetic improvements, there’s improved functionality in the new template. The template employs a technique called adaptive rendering to look good in both desktop browsers and mobile browsers without any customization.
  • To see adaptive rendering in action, you can use a mobile emulator or just try resizing the desktop browser window to be smaller. When the browser window gets small enough, the layout of the page will change.
  • Mobile Project Template:
  • If you’re starting a new project and want to create a site specifically for mobile and tablet browsers, you can use the new Mobile Application project template. This is based on jQuery Mobile, an open-source library for building touch-optimized UI.
  • Display Modes:
  • The new Display Modes feature lets an application select views depending on the browser that's making the request. For example, if a desktop browser requests the Home page, the application might use the Views\Home\Index.cshtml template. If a mobile browser requests the Home page, the application might return the Views\Home\Index.mobile.cshtml template.
  • Layouts and partials can also be overridden for particular browser types.
  • jQuery Mobile and Mobile Features
  • Task Support for Asynchronous Controllers:
  • You can now write asynchronous action methods as single methods that return an object of type Task or Task.
  • Azure SDK:
  • ASP.NET MVC 4 supports the 1.6 and newer releases of the Windows Azure SDK.
  • Database Migrations:
  • ASP.NET MVC 4 projects now include Entity Framework 5. One of the great features in Entity Framework 5 is support for database migrations. This feature enables you to easily evolve your database schema using a code-focused migration while preserving the data in the database.
  • Empty Project Template:
  • The MVC Empty project template is now truly empty so that you can start from a completely clean slate. The earlier version of the Empty project template has been renamed to Basic.
  • Add Controller to any project folder:
  • You can now right click and select Add Controller from any folder in your MVC project. This gives you more flexibility to organize your controllers however you want, including keeping your MVC and Web API controllers in separate folders.
  • Bundling and Minification:
  • The bundling and minification framework enables you to reduce the number of HTTP requests that a Web page needs to make by combining individual files into a single, bundled file for scripts and CSS. It can then reduce the overall size of those requests by minifying the contents of the bundle. Minifying can include activities like eliminating whitespace to shortening variable names to even collapsing CSS selectors based on their semantics. Bundles are declared and configured in code and are easily referenced in views via helper methods which can generate either a single link to the bundle or, when debugging, multiple links to the individual contents of the bundle.
  • Enabling Logins from Facebook and Other Sites Using OAuth and OpenID:
  • The default templates in ASP.NET MVC 4 Internet Project template now includes support for OAuth and OpenID login using the DotNetOpenAuth library.
  • Changes from ASP.NET MVC 4 Release Candidate:
  • Per controller configuration: ASP.NET Web API controllers can be attributed with a custom attribute that implements IControllerConfiguration to setup their own formatters, action selector and parameter binders. The HttpControllerConfigurationAttribute has been removed.
  • Per route message handlers: You can now specify the final message handler in the request chain for a given route. This enables support for ride-along frameworks to use routing to dispatch to their own (non-IHttpController) endpoints.
  • Progress notifications: The ProgressMessageHandler generates progress notification for both request entities being uploaded and response entities being downloaded. Using this handler it is possible to keep track of how far you are uploading a request body or downloading a response body.
  • Push content: The PushStreamContent class enables scenarios where a data producer wants to write directly to the request or response(either synchronously or asynchronously) using a stream. When the PushStreamContent is ready to accept data it calls out to an action delegate with the output stream. The developer can then write to the stream for as long as necessary and close the stream when writing has completed. The PushStreamContent detects the closing of the stream and completes the underlying asynchronous Task for writing out the content.
  • Creating error responses: Use the HttpError type to consistently represent error information from such as validation errors and exceptions while still honoring the IncludeErrorDetailPolicy. Use the new CreateErrorResponse extension methods to easily create error responses with HttpError as content. The HttpError content is fully content negotiated.
  • MediaRangeMapping removed: Media type ranges are now handled by the default content negotiator.
  • Default parameter binding for simple type parameters is now [FromUri]: In previous releases of ASP.NET Web API the default parameter binding for simple type parameters used model binding. The default parameter binding for simple type parameters is now [FromUri].
  • Action selection honors required parameters: Action selection in ASP.NET Web API will now only select an action if all required parameters that come from the URI are provided. A parameter can be specified as optional by providing a default value for the argument in the action method signature.
  • Customize HTTP parameter bindings: Use the ParameterBindingAttribute to customize the parameter binding for a specific action parameter or use the ParameterBindingRules on the HttpConfiguration to customize parameter bindings more broadly.
  • MediaTypeFormatter improvements: Formatters now have access to the full HttpContent instance.
  • Host buffering policy selection: Implement and configure the IHostBufferPolicySelector service in ASP.NET Web API to enable hosts to determine the policy for when buffering is to be used.
  • Access client certificates in a host agnostic manner: Use the GetClientCertificate extension method to get the supplied client certificate from the request message.
  • Content negotiation extensibility: Customize content negotiation by deriving from the DefaultContentNegotiator and overriding any aspect of content negotiation that you would like.
  • Support for returning 406 Not Acceptable responses: You can now return 406 Not Acceptable responses in ASP.NET Web API when a suitable formatter is not found by creating a DefaultContentNegotiator with the excludeMatchOnTypeOnly parameter set to true.
  • Read form data as NameValueCollection or JToken: You can read form data in the URI query string or in the request body as a NameValueCollection using the ParseQueryString and ReadAsFormDataAsync extension methods respectively. Similarly, you can read form data in the URI query string or in the request body as a JToken using the TryReadQueryAsJson and ReadAsAsync extension methods respectively.
  • Multipart improvements: It is now possible to write a MultipartStreamProvider that is completely tailored to the type of MIME multipart data that it can read and present the result in the optimal way to the user. You can also hook a post processing step on the MultipartStreamProvider that allows the implementation to do whatever post processing it wants on the MIME multipart body parts. For example, the MultipartFormDataStreamProvider implementation reads the HTML form data parts and adds them to a NameValueCollection so they are easy to get at from the caller.
  • Link generation improvements: The UrlHelper no longer depends on HttpControllerContext. You can now access the UrlHelper from any context where the HttpRequestMessage is available.
  • Message handler execution order change: Message handlers are now executed in the order that they are configured instead of in reverse order.
  • Helper for wiring up message handlers: The new HttpClientFactory that can wire up DelegatingHandlers and create an HttpClient with the desired pipeline ready to go. It also provides functionality for wiring up with alternative inner handlers (the default is HttpClientHandler) as well as do the wiring up when using HttpMessageInvoker or another DelegatingHandler instead of HttpClient as the top-invoker.
  • Support for CDNs in ASP.NET Web Optimization: ASP.NET Web Optimization now provides support for CDN alternate paths enabling you to specify for each bundle an additional URL which points to that same resource on a content delivery network. Supporting CDNs enables you to get your script and style bundles geographically closer to the end consumers of your Web applications.
  • ASP.NET Web API routes and configuration moved to WebApiConfig.Register static method that can be resused in test code. ASP.NET Web API routes previously were added in RouteConfig.RegisterRoutes along with the standard MVC routes. The default ASP.NET Web API routes and configuration are now handled in a separate WebApiConfig.Register method to facilitate testing.

New in Microsoft ASP.NET MVC 4 Beta (Feb 16, 2012)

  • Enhancements to Default Project Templates:
  • The template that is used to create new ASP.NET MVC 4 projects has been updated to create a more modern-looking website.
  • In addition to cosmetic improvements, there’s improved functionality in the new template. The template employs a technique called adaptive rendering to look good in both desktop browsers and mobile browsers without any customization. To see adaptive rendering in action, you can use a mobile emulator or just try resizing the desktop browser window to be smaller. When the browser window gets small enough, the layout of the page will change.
  • Another enhancement to the default project template is the use of JavaScript to provide a richer UI. The Login and Register links that are used in the template are examples of how to use the jQuery UI Dialog to present a rich login screen.
  • Mobile Project Template:
  • If you’re starting a new project and want to create a site specifically for mobile and tablet browsers, you can use the new Mobile Application project template. This is based on jQuery Mobile, an open-source library for building touch-optimized UI. This template contains the same application structure as the Internet Application template (and the controller code is virtually identical), but it's styled using jQuery Mobile to look good and behave well on touch-based mobile devices.
  • Display Modes:
  • The new Display Modes feature lets an application select views depending on the browser that's making the request. For example, if a desktop browser requests the Home page, the application might use the Views\Home\Index.cshtml template. If a mobile browser requests the Home page, the application might return the Views\Home\Index.mobile.cshtml template.
  • Layouts and partials can also be overridden for particular browser types.
  • Recipes for Code Generation in Visual Studio:
  • The new Recipes feature enables Visual Studio to generate solution-specific code based on packages that you can install using NuGet. The Recipes framework makes it easy for developers to write code-generation plugins, which you can also use to replace the built-in code generators for Add Area, Add Controller, and Add View. Because recipes are deployed as NuGet packages, they can easily be checked into source control and shared with all developers on the project automatically. They are also available on a per-solution basis.
  • Task Support for Asynchronous Controllers:
  • You can now write asynchronous action methods as single methods that return an object of type Task or Task.
  • Azure SDK:
  • ASP.NET MVC 4 Developer Preview supports the September 2011 1.5 release of the Windows Azure SDK.

New in Microsoft ASP.NET MVC 3 Beta (Oct 8, 2010)

  • New Features :
  • NuPack Package Manager
  • Improved New Project Dialog Box
  • Simplified Way to Specify Strongly Typed Models in Razor Views
  • Support for New ASP.NET Web Pages Helper Methods
  • Additional Dependency Injection Support
  • New Support for Unobtrusive jQuery-Based Ajax
  • New Support for Unobtrusive jQuery Validation
  • New Application-Wide Flags for Client Validation and Unobtrusive JavaScript
  • New Support for Code that Runs Before Views Run
  • New Support for the VBHTML Razor Syntax
  • More Granular Control over ValidateInputAttribute
  • Helpers Convert Underscores to Hyphens for HTML Attribute Names Specified Using Anonymous Objects
  • Bug Fixes:
  • The default object template for the EditorFor and DisplayFor template helpers now supports the ordering specified in the DisplayAttribute.Order property. (In previous versions, the Order setting was not used.)
  • Client validation now supports validation of overridden properties that have validation attributes applied.
  • JsonValueProviderFactory is now registered by default.

New in Microsoft ASP.NET MVC 3 Preview 1 (Jul 28, 2010)

  • Razor View Engine
  • Dynamic View and ViewModel Properties
  • "Add View" Dialog Box Supports Multiple View Engines
  • Service Location and Dependency Injection Support
  • Global Filters
  • New JsonValueProviderFactory Class
  • Support for .NET Framework 4 Validation Attributes and IValidatableObject
  • New IClientValidatable Interface
  • Support for .NET Framework 4 Metadata Attributes
  • New IMetadataAware Interface
  • Permanent Redirect
  • New Action Result Types:
  • HttpNotFoundResult Action
  • HttpStatusCodeResult Action

New in Microsoft ASP.NET MVC 2 RTM (Mar 12, 2010)

  • Fixed a bug that caused Internet Explorer versions 6, 7, and 8 (in compatibility mode) to hang when client validation is used in certain scenarios.
  • Breaking Changes

New in Microsoft ASP.NET MVC 2 RC2 (Feb 5, 2010)

  • Every property for model objects that use IDataErrorInfo to perform validation is validated, regardless of whether a new value was set. (See Default validation system validates entire model earlier in this document.) In ASP.NET MVC 1.0, only properties that had new values set would be validated. In ASP.NET MVC 2, the Error property of IDataErrorInfo is called only if all the property validators were successful.

New in Microsoft ASP.NET MVC 2 RC1 (Feb 5, 2010)

  • IIS script mapping script is no longer available in the installer
  • The IIS script mapping script is a command-line script that is used to configure script maps for IIS 6 and for IIS 7 in Classic mode. The script-mapping script is not needed if you use the Visual Studio Development Server or if you use IIS 7 in Integrated mode. The scripts are available as a separate unsupported download on the ASP.NET CodePlex site.
  • The Html.Substitute helper method in MVC Futures is no longer available
  • Due to changes in the rendering behavior of MVC view engines, the Html.Substitute helper method does not work and has been removed.

New in Microsoft ASP.NET MVC 2 Beta (Feb 5, 2010)

  • The IValueProvider interface replaces all uses of IDictionary
  • Every property or method argument that accepted IDictionary now accepts IValueProvider. This change affects only applications that include custom value providers or custom model binders.
  • Examples of properties and methods that are affected by this change include the following:
  • The ValueProvider property of the ControllerBase and ModelBindingContext classes.
  • The TryUpdateModel methods of the Controller class.
  • New CSS classes were added in the Site.css file that are used to style validation messages.

New in Microsoft ASP.NET MVC 2 Preview 2 (Feb 5, 2010)

  • Helpers now return an MvcHtmlString object
  • In order to take advantage of the new HTML-encoding expression syntax in ASP.NET 4, the return type for HTML helpers is now MvcHtmlString instead of a string. Note that if you use ASP.NET MVC 2 and the new helpers with ASP.NET 3.5, you will not be able to take advantage of the HTML-encoding syntax; the new syntax is available only when you run ASP.NET MVC 2 on ASP.NET 4.
  • JsonResult now responds only to HTTP POST requests
  • In order to mitigate JSON hijacking attacks that have the potential for information disclosure, by default, the JsonResult class now responds only to HTTP POST requests. Ajax GET calls to action methods that return a JsonResult object should be changed to use POST instead. If necessary, you can override this behavior by setting the new JsonRequestBehavior property of JsonResult. For more information about the potential exploit, see the blog post JSON Hijacking on Phil Haack’s blog.
  • Model and ModelType property setters on ModelBindingContext are obsolete
  • A new settable ModelMetadata property has been added to the ModelBindingContext class. The new property encapsulates both the Model and the ModelType properties. Although the Model and ModelType properties are obsolete, for backward compatibility the property getters still work; they delegate to the ModelMetadata property to retrieve the value.
  • Changes in ASP.NET MVC 2 Preview 1

New in Microsoft ASP.NET MVC 2 Preview 1 (Feb 5, 2010)

  • Changes to the DefaultControllerFactory class break custom controller factories that derive from it
  • The DefaultControllerFactory class was fixed by removing the RequestContext property. In place of this property, the request context instance is passed to the protected virtual GetControllerInstance and GetControllerType methods. This change affects custom controller factories that derive from DefaultControllerFactory.
  • Custom controller factories are often used to provide dependency injection for ASP.NET MVC applications. To update the custom controller factories to support ASP.NET MVC 2, change the method signature or signatures to match the new signatures, and use the request context parameter instead of the property.
  • “Area” is a now a reserved route-value key
  • The string “area” in Route values now has special meaning in ASP.NET MVC, in the same way that “controller” and “action” do. One implication is that if HTML helpers are supplied with a route-value dictionary containing “area”, the helpers will no longer append “area” in the query string.
  • If you are using the Areas feature, make sure to not use {area} as part of your route URL.