ASP.NET vNext, a quick look into the future

  1. MVC Controllers and WebAPI Controllers are now merged to form single controller class

    1. 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
    2. Route mapping looks a bit better now with the following syntax

      // MVC 6 route
      routes.MapRoute(
      name: "Default",
      template: "{controller=Home}/{action=Index}/{id?}"
      );
      

    3. 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

    4. 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!)

      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