BT

New Features for ASP.NET 5 and MVC 6

| by Jonathan Allen Follow 575 Followers on Jul 21, 2015. Estimated reading time: 1 minute |

While most of the buzz has been about ASP.NET 5 and the cross-platform execution engine, MVC, Microsoft’s preferred UI and web service framework, is also seeing many changes. The most important being the unification of MVC, Web API, and Web Pages.

It almost goes without saying that Razor, the default rendering engine for MVC 6, will but upgraded to support C# 6. But that’s not the only new feature for Razor.

There are times when it is preferable to embed some JSON data right in the webpage rather than paying for a separate call to the server. This used to involve some tedious mapping code to run the data objects through a JSON converter and expose the result via the view model. In MVC 6, all of that boilerplate has been reduced to just “@Json.Serialize(Model)”.

Another place where boilerplate code has been a problem is image caching. Caching the image is easy, but finding ways to signal to the browser that the cache is no longer valid tends to involve tedious workarounds. With the image tag helper, that becomes as simple as setting the asp-file-version attribute to true. This will cause MVC to “to automatically append image filenames with a cache-buster version number”.

The tag helper framework has also seen some improvements. You can now “bind server side attributes to dictionary properties on your tag helpers”. Tag helpers can also be conditionally activated by the presence of server-side attributes. For more information on writing your own tag helpers, see Jeff Fritz’s article, Get Started with ASP.NET MVC TagHelpers.

Route tokens allow you to write expressions such as “[Route("Products/[action]")” at the class level. With MVC 6, the same tokens can be used in the route name, which can be helpful for diagnostic purposes.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Nice! by neel bhatt

Nice! Please refer this for your first application with MVC 6 :

neelbhatt40.wordpress.com/2015/08/27/hello-world-with-mvc-6

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT