ASP.NET vNext, a quick look into the future

  1. MVC Controllers and WebAPI Controllers are now merged to form single controller class
  2. No need for physical folders for Areas, just decorating a Controller with [Area(“AreaName”)] gets you the desired result. But the problem is rendering engines still look for Views in Areas/{area name}/Views/{controller} path. So I guess you are better of placing your Controllers also in Areas/{area name}/Controller folder for better organizing them
  3. Route mapping looks a bit better now with the following syntax
1
2
3
4
5
// MVC 6 route
routes.MapRoute(
    name: "Default";,
    template: "{controller=Home}/{action=Index}/{id?}";
);
  1. Even if you omit the {action} token from the route template, your Controllers can still respond to Action names corresponding to the Request method (GET, POST, UPDATE…). So, this neatly ties up the merger of MVC Controllers and WebAPI Controllers
  2. OWIN and Katana seems to be all the rage now, and for good reasons. So, the startup scripts looks thus (no need for Global.asax .. will miss you my friend!)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;

public class Startup
{
    public void Configure(IBuilder app)
    {
        app.UseServices(services =>
        {
            services.AddMvc();
        });

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: ";Default";,
                template: "{controller=Home}/{action=Index}/{id?}";);
        });

    }
}
  1. Now your Visual Studio project file is a simple JSON file, instead of the lengthy XML one

So, overall seems to be a nice upgrade.

Do check out Getting started with MVC 6 for a more elaborate look into the features.

comments powered by Disqus