Monthly Archives: July 2015

ViewComponents in ASP.NET 5 and ASP.NET MVC 6

Let’s have a quick look at another new feature in ASP.NET MVC 6, and that is the ViewComponent feature. View components are intended to be replacements to ChildActions and, to some extent, of partial views.

Traditionally in ASP.NET MVC (and in general in the textbook MVC pattern), you had to compose the entire model in the controller and pass it along to the view, which simply rendered the entire page based on the data from the model. The consequence of this is that the view does not need to explicitly ask for any data – as its sole purpose is to just act upon the model it received.

While this sounds very nice in theory, it has traditionally posed a number of practical difficulties. There are a number of reusable components on pretty much every website – think a menu, a shopping cart, lists of all kinds, breadcrumbs, metadata and so on – so things that appear on multiple pages.

Let’s have a look at how this is solved in MVC 6.

Continue Reading

Migrating from Web API 2 to MVC 6 at NDC Oslo

Screenshot 2015-07-09 11.59.00Last month I gave a talk about migrating from Web API to MVC 6 and ASP.NET 5 at NDC Oslo.

Below you can find the the video, code and slides from the session.

Thanks for all who attended, I had a great time in Oslo! Hopefully we get to revisit this session soon too, when ASP.NET 5 becomes a bit more mature.


You can watch the talk on Vimeo.
And if you are wondering, yes I’m wearing a Bayern Munich jersey on stage :)


All the code is hosted at Gtihub. It contains the Web API 2 project, the MVC 6 “before” and the MVC 6 “after” version. It’s built using beta6 nightlies so you’ll need to install those to run the code.


Just go to this URL. Slides are also contained in the Github repository – powered by the almighty FsReveal.
Mind you this talk is all about code so there aren’t many slides anyway.