ASP.NET vNext Blog Post Series
- by Soe Tun
Originally posted on: http://geekswithblogs.net/stun/archive/2014/06/04/asp.net-vnext-blog-post-series.aspxASP.NET vNext Blog Post Series
ASP.NET vNext was announced at TechEd 2014, and I have been playing around with it a bit. ASP.NET vNext is an exciting and revolutionary change for the Microsoft .NET development platform. ASP.NET vNext is now open-source, and available on Github at this location: https://github.com/aspnet/Home.
I want to start a blog post series on the ASP.NET vNext, and share my experience as I learn more about it.
Keeping it simple
Each blog post in the series will be short and simple so I can write them in a short amount of time, and keep it focused on one (at most two) topic(s) per post.
My goal is to make it easy to absorb the information as there are a ton of great new stuff to cover.
Many other people in the community have blogged about the key new features of the ASP.NET vNext.
I will link to those blog posts in my next blog post.
MVC 6 POCO Controller
Today, I want to start this blog post series with a teaser code snippet for those developers familiar with the ASP.NET MVC.
Getting Started with ASP.NET MVC 6 article from ASP.NET website shows how to write a lightweight POCO (plain-old CLR object) MVC Controller class in the upcoming ASP.NET MVC 6.
However, it doesn't show us how to use the IActionResultHelper interface to render a View.
This is how I wrote my POCO MVC Controller based on the https://github.com/aspnet/Home/blob/master/samples/HelloMvc/Controllers/HomeController.cs sample from Github.
Note that this may not be the best way to write it, but this is good enough for now.
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ModelBinding;
using MvcSample.Web.Models;
namespace MvcSample.Web
{
public class HomeController
{
IActionResultHelper html;
IModelMetadataProvider mmp;
public HomeController(IActionResultHelper h, IModelMetadataProvider mmp)
{
this.html = h;
this.mmp = mmp;
}
public IActionResult Index()
{
var viewData = new ViewDataDictionary<User>(mmp) { Model = User() };
return html.View("Index", viewData);
}
public User User()
{
return new User { Name = "My name", Address = "My address" };
}
}
}
Please feel free to give me feedback as this will greatly help me organize the blog posts in this series, and plan head.
Thanks for reading!