
The next year is passing, and it’s time to work on the new ASP.NET MVC release. The information below covers general roadmap information for the ASP.NET MVC 4 framework.
It is important to understand that we are in the early development of ASP.NET MVC 4 and the roadmap is a document that is planned for the next release. This is not a specification describing how it will be. We just hope to implement most of the description below, but there is no guarantee that this will work out. Plans change, and you can help change them! To do this, please leave your feedback on our
Uservoice site , so that we have a greater idea of what you want to see in the new release.
')
Goals
Before analyzing the proposed functions, let's consider the main goals of the release. For the sake of a great and wonderful goal, we set ourselves the task of making ASP.NET MVC the best platform for creating modern “rich” web applications. Therefore, we have focused on those ASP.NET MVC 4 (and network stack) functions that will bring us closer to accomplishing this goal.
Directions
Before planning for specific functionality, our team working on ASP.NET compiled a list of key areas for development and planning. Some of them are not typical of ASP.NET MVC, that is, we can not cope with them only with our team, so the work will be done with colleagues from and outside Microsoft:
- development and deployment: we want to make the development and deployment process more transparent, more sophisticated, and faster;
- focus on the platform: the Razor view engine and some new helpers in ASP.NET MVC 3 emerged from the work on ASP.NET Web Pages. We will continue to devote attention to the functionality of the web platform, which we will be able to further integrate into ASP.NET MVC;
- Ajax : tasks can consist of simply adding Ajax to existing applications or creating a full-fledged one-page application (such as Gmail), for any of them we are looking for ways to better integrate Ajax with ASP.NET MVC. We already have a couple of ideas and we are busy with the planning process to identify and understand the difficult issues that we can fix;
- HTML 5, tablets and mobile devices: there is currently a trend in the industry to create mobile and tablet software by simply programming HTML5 web applications. The HTML5 application runs on most devices and has the widest range of distribution methods. However, writing an application for mobile and tablet devices requires a certain amount of experience, and we want to simplify this process;
- Cloud : We would like to see the task of deploying and hosting web applications in the clouds (for example, on Windows Azure) easier and faster. To get the most out of the clouds, we will focus on performance, security, and scalability.
Functionality
Now what you wanted is functionality! Please note that some descriptions are presented in a much more detailed form than the rest.
Recipes (recipes - task-based extension tools)
Solving some tasks requires manipulating many aspects of the application. Suppose, if you need to add an Ajax Grid to a view, you generate view code for rendering the Grid HTML markup, create DAO classes for display in the Grid, and add a controller asynchronously called by the Ajax Grid for receiving data. Recipes are designed to help you in this process.
An ASP.NET MVC 4 recipe is a dialog box supplied by NuGet with its UI and code used to automate a task. Let's take an example: the implementation of authentication based on OAuth cannot be simplified to calling a single method, because Oauth requires setting a lot of settings and UI. A new recipe functionality for solving this problem can be represented as a UI, which will ask questions about the required settings and generate all the code based on the answers.
Examples of what can be done with recipes:
- Ajax grid
- OAuth-based authentication
- Support for authentication based on the Windows Identity Framework (WIF)
Writing, deploying and installing recipes
In order to write a recipe, you only need to implement a dialog box using the recipe API. The dialog box provides an instance of the MVC project interface, which is easier to use than the EnvDTE.DTE interface, typically used to automate tasks in Visual Studio.
For example, the process of adding a controller to an area within an ASP.NET MVC project using DTE can be paired with calling multiple methods, while the recipe API narrows this set to one.
After writing the dialog box, you need to pack it in a NuGet package and now everyone who needs it can install and use your recipe.
Recipe- "blanks"
The "pig" below is an example of how recipes can work. To start the recipe, you will need to right-click on the project in the Solution Explorer (or file) and click
Run Recipe to display the menu with the list of recipes. (This may also look like the
Run Recipes option submenu.)

The list of available recipes is determined by the list of recipes installed using NuGet. Click on the recipe to call the UI defined by the recipe itself.

Recipes can look like a simple dialog box (or, theoretically, without dialog boxes at all) or be step wizards. Clicking
Finish will lead to the execution of the talk with the settings you specified.
Recipe API
The idea for the API is for the developer to have an instance of the project interface containing the launch context for the recipe. This interface provides a simple “facade” in the style of an MVC design system without having to learn the entire set of DTE interfaces. However, the recipe API allows access to the DTE in cases where the interface functions are insufficient
.Embedded Recipes
As one of the works, we plan to provide some set of embedded recipes. Options: OAuth, Ajax grid, WIF. Including we are considering other options.
Mobile support
Mobile devices, such as phones and tablets, continue to gain popularity as a means to access the Internet. When developing a site for the masses, you must also take into account the fact that you will provide access to the resource to visitors with small displays and a touch-screen. In ASP.NET MVC 4, we aimed to provide you with simple and at the same time flexible methods to cover the issues of mobile device support both when developing a new site and improving an existing one.
Default Template Changes
One of the improvements is changing the markup and CSS in the default templates. New designs look as good on a mobile device as on desktops. For example, we added a viewport meta tag, so the pages look good on small displays, discarding the need for zoom. Below is a comparison of pages created with different templates:

New project template “Mobile Application”
The following change concerns a project template specifically for mobile and tablet web applications. This template includes markup, views, scripts (such as jQuery Mobile) specially designed for creating applications that provide a rich interface and are optimized for modern mobile devices. For example, a page from this template might look like this:

Device-Specific Views
Often it is necessary to adapt an existing UI to a user device. We want to simplify changing views, partial views, and markup for special types of devices. This feature will work regardless of whether you create a new project or upgrade an existing one to ASP.NET MVC 4.
For example, you can change specific views for mobile devices by creating additional views with the suffix “.Mobile” in the file name:

We can provide new jQuery Mobile-based view templates and improve the Add View and Add Controller dialog boxes to quickly add jQuery Mobile-based views that overlap existing controllers and actions
. The following example demonstrates a “blank” of what an
Add Controller might look like:

Options in the
View type are independent of the view engine used by the application. Options that can rarely change from view to view are transferred to the
View Options :

Device switcher
One of the practices on many websites is the practice of providing the ability to simply switch from mobile to desktop view. We plan to add a device switcher, which is also a helper for rendering the corresponding UI (“switch” links from mobile to desktop view or vice versa) and an API to allow the user to choose the view he wants.
Razor Helpers Support
ASP.NET Web Pages provides support for writing helper methods using the Razor syntax by adding .cshtml or .vbhtml files to the App_Code project directory. It is possible to add these files to an ASP.NET MVC project, but even so, the files will not have access to ASP.NET MVC context objects (such as ViewContext) or an ASP.NET MVC HtmlHelper instance.
In ASP.NET MVC 4, we will add support for Razor helpers, which can work in ASP.NET MVC style. We are also exploring the possibility of creating tools for writing Razor-helpers that could be compiled into libraries
. This would make it really possible to use these libraries in other projects and test them with unit tests.
Task and Task <T> support for AsyncController classes
Writing asynchronous action methods with existing versions of ASP.NET MVC can be confusing. For example, the following ASP.NET MVC 3 snippet demonstrates an action method that calls two different asynchronous services.
public void IndexAsync(string city) { AsyncManager.OutstandingOperations.Increment(2); NewsService newsService = new NewsService(); newsService.GetHeadlinesCompleted += (sender, e) => { AsyncManager.Parameters["headlines"] = e.Value; AsyncManager.OutstandingOperations.Decrement(); }; newsService.GetHeadlinesAsync(); SportsService sportsService = new SportsService(); sportsService.GetScoresCompleted += (sender, e) => { AsyncManager.Parameters["scores"] = e.Value; AsyncManager.OutstandingOperations.Decrement(); }; sportsService.GetScoresAsync(); } public ActionResult IndexCompleted(string[] headlines, string[] scores, string[] forecast) { return View("Common", new PortalViewModel { NewsHeadlines = headlines, SportsScores = scores, }); }
With ASP.NET MVC 4 and
Visual Studio Async CTP (or when C # 5 is released that supports the
await keyword ), this snippet will look like this:
public async Task<ActionResult> Index(string city) { var newsService = new NewsService(); var sportsService = new SportsService(); return View("Common", new PortalViewModel { NewsHeadlines = await newsService.GetHeadlinesAsync(), SportsScores = await sportsService.GetScoresAsync() }); }
Packing CSS and JavaScript
ASP.NET MVC 4 will include the ability to automatically pack CSS and JavaScript files. Packaging combines different .css and .js files into one file and reduces the total size by removing unnecessary blank lines and spaces and comments (minification). This will reduce both the amount of traffic and load time, as well as accelerate the rendering of web pages.
Other functionality
We did not devote time to a similar review of each innovation that is under consideration. The following is a list of very interesting functionality, some of which are implemented by other teams.
- EF Code First Data Migrations provides support for switching from one version of the database schema to another without losing data;
- improved support for functional and integration testing code;
- WCF Web API support;
- Ajax improvements - we are focused on reducing the efforts that the developer makes in using Ajax with ASP.NET MVC;
- HTML5 support in edit / display templates and HTML helpers. For example, editing templates will be able to render input with the date type to display the DateTime property instead of the usual input with the text type. In addition, existing HTML TextBoxFor helpers can also be rendered with appropriate input based on the type of model provided;
- templates for web projects for mobile devices;
- support for “donut hole” caching in Razor views and the Windows Server App Fabris caching provider;
- The new class AreaAttribute to provide a better level of security when using the area (area) mechanism.
PS: special thanks to Alexander Belotserkovsky for help with the translation.