Getting started with ASP.NET vNext

ASP.NET vNext is the next version of the ASP.NET web framework. The focus this time around is strip out unnecessary bits and make a leaner, meaner, easier-to-use framework.

A few of the things done include:

  • Side by side deployment of .NET – you can deploy all code, dependencies and the .NET framework in the bin directory of your site
  • A cloud optimized version of .NET, which is very lean. The full .NET is above 200mb, the cloud optimized version is ~11mb
  • ASP.NET Web API and ASP.NET MVC are now merged into one framework
  • No dependency on IIS. You can host your sites in IIS, or you can host it in your own, custom process
  • A new project.json file that holds references and configuration for the project
  • You can compile C# using the Roslyn compilers, which means no dependency on MSBuild or Visual Studio

ASP.NET vNext Home

To start playing with vNext, go to the ASP.NET vNext repo on GitHub and clone it. The Home repository is a starting point that includes samples and documentation.

After you have the project cloned, run:

kvmsetup.cmd

This will download any necessary framework files and dependencies. KVM is the K Version Manager, which is what allows you to download and manage multiple versions of the K runtime. Next, run

kvm install 0.1-alpha-build-0421

This will download and install the 0421 build of the K Runtime and place it in your user profile. (0421 was the latest build as of this post. You can upgrade the version by running kvm upgrade)

We’ll focus on the ASP.NET MVC sample, so navigate to Samples/HelloMvc and run

kpm restore

This will look into project.json and will load all dependencies required for the project.

Finally, run

K web

This will start the K runtime and will attempt to start the web configuration specified in the project.json file. This configuration tells the runtime to start up and listen on port 5001.

If you navigate to http://localhost:5001 you should see the welcome page for the site. Hooray! From here, you can add more controllers, views, etc and build out a site. When it comes time to release, you can copy your project directory up to your server, run K web and have your site running without ever installing .NET. The Lesser Scotts even copied their project to a USB key and ran it off of that. Awesome.

No Visual Studio!??

What’s very cool about this is there is no dependency on Visual Studio or MSBuild. You can, if you so desire, develop in notepad, notepad++, vim, or whatever other app you want. The Roslyn compilers allow for this to happen – all you have to do while developing is change a file, save it, and refresh your browser. This makes it a much easier, seamless, awesome programming experience.

With ASP.NET vNext Microsoft is making an effort to make developing .NET applications easier. There is no need to install a massive framework, less compile and load time, and all of this is open source. It’s very, very exciting.