In the interest of aiming high and reaching big, goal is to make ASP.NET MVC the best web platform for building modern rich web apps. So we’re focusing on features in ASP.NET MVC 4 (and across the web stack) that will get us closer to reaching this goal.
Before planning specific features, the ASP.NET team came up with a set of themes to guide our planning. Some of these themes are not specific to ASP.NET MVC, which means we can’t fulfill these themes solely within the ASP.NET MVC feature team. We’ll be working with partners across and outside of Microsoft to help us reach these goals.
- Development and deployment: We want to smooth out the development and deployment workflow to be easier, better, and faster.
- Capitalize on the platform: The Razor view engine and some of the new helpers in ASP.NET MVC 3 came out of work done for ASP.NET Web Pages. We’ll continue to invest in shared features throughout the web platform that we can incorporate into ASP.NET MVC.
- Ajax: Whether it be adding a dash of Ajax to an existing web application or implementing a full-fledged single-page application (e.g. Gmail), we are looking at ways to improve the Ajax development story within ASP.NET MVC. We have a few ideas already, but we’re deep in the process of application building to help us expose and understand pain points that we can fix.
- HTML5, tablet, and mobile: There’s an industry trend towards building mobile and tablet applications by simply building an HTML5 web application. An HTML5 application provides the widest possible distribution option and runs on the widest set of devices. But writing an app geared towards mobile and tablet devices takes experience. We want to make it easier to get started building such applications.
- Cloud ready: We want the task of deploying and hosting web applications in the cloud (such as on Windows Azure) to be quick and easy. In order to get the most from the cloud, we’ll focus on performance, security, and scalability.
And now, to the part you really want to hear about—the features! Note that some features are much more fleshed out than others.
Recipes (Extensible Task-Based Tooling)
Some tasks require you to manipulate multiple sections of an application. For example, if you want to add an Ajax grid to a view, you’ll need to generate the view code to render the HTML markup for the grid, create the data-access classes to display in the grid, and add the controller class that the Ajax grid can call asynchronously to retrieve the data. Recipes are going to help with that.
An ASP.NET MVC 4 recipe is a dialog box delivered via NuGet with associated user interface (UI) and code used to automate a specific task. For example, implementing OAuth-based authentication will probably never be as simple as calling a single method, because it requires multiple settings and multiple pieces of UI. A recipe for implementing OAuth authentication might therefore provide a UI that asks you for the settings and then generates all the necessary code.
Some ideas for potential recipes include the following:
- Ajax grid
- Implementing OAuth-based authentication
- Support for claims-based authentication using Windows Identity Framework (WIF)
For the API, the idea is that the recipe developer gets an instance of a project interface that includes context about how the recipe was launched. This interface will provide an easy-to-use façade over the MVC project system without requiring the developer to learn the full DTE set of interfaces. However, the interface does provide access to the DTE in case the project interface is not sufficient.
As part of this work, we’re planning to build a number of built-in recipes. Candidates include OAuth support, Ajax grid, and WIF, as noted earlier. We’re looking for more ideas as well.
Mobile devices – phones and tablets – continue to grow in popularity as a means to browse the web. If you’re building a site for the public, you’ll want to consider what kind of experience you’re offering to visitors who have small screens or touch-enabled screens. With ASP.NET MVC 4, we’re aiming to give you straightforward but flexible ways to implement first-class mobile support, whether you’re creating a new site or enhancing one you already have.
Default Template Changes
One improvement is a change to the default project templates’ markup and CSS so that all newly created projects look good out of the box on mobile devices as well as on desktops. For example, we’re adding the viewport meta tag so that pages lay out well on small screens and don’t force as much awkward zooming in and out as pages designed solely for the desktop. The following shows a comparison of pages built with the old and (proposed) new template:
It’s often desirable to tailor user interfaces to match the user’s device. We’d like to make it easy to override views, partial views, and layouts for particular device types. This feature would work whether you’re creating a brand-new new project or upgrading an existing one to ASP.NET MVC 4.
One practice on many websites is to provide a simple way for visitors to switch from a mobile experience to a desktop experience. We’re considering adding a device switcher that is both a helper for rendering the appropriate UI (a link to switch from mobile to desktop or vice versa depending on the current device setting) as well as an API for letting users determine which experience they prefer.
Razor Helpers Support
ASP.NET Web Pages provides support for writing helper methods using Razor syntax by adding .cshtml or .vbhtml files to the App_Code directory of a web application. It’s possible to add these files to an ASP.NET MVC project, but even if you do, those files don’t have access to the ASP.NET MVC context objects (such as ViewContext) or to the ASP.NET MVC HtmlHelper instance.
In ASP.NET MVC 4, we’ll add support for Razor helpers that work in an MVC-specific way. We’re also investigating tooling support for writing Razor helpers in a class library project so that they can be compiled into libraries. This would make it possible to reuse these libraries in other projects as well as write unit tests against them.
Task and Task Support for AsyncController Classes
Writing asynchronous action methods has been tricky with existing versions of ASP.NET MVC. For example, the following ASP.NET MVC 3 code snippet shows an example of an action method that calls into two different asynchronous services.
- We haven’t spent time fleshing out every feature under consideration. The following items are on the top of our mind. Some of them will be delivered by other teams.
- EF Code First Data Migrations. This provides support for migrating from one version of your database schema to the next without losing data.
- Better support for functional and integration testing of application code.
- WCF Web API support.
- Ajax improvements across the board. We’re focusing reducing the friction that developers encounter when using Ajax with ASP.NET MVC.
- HTML5 support for editor/display templates and HTML helpers. For example, editor templates to might render an input element with its type set to date instead of an input element with its type set to the default text when rendering a DateTime property. Likewise, existing HTML helpers such as TextBoxFor might also be updated to render an appropriate input element based on the model type.
- Templates for mobile web projects.
- Support for “donut hole” caching in Razor views and support for the Windows Server App Fabric caching provider.
- A new AreaAttribute class for better security when using areas.