Converting to ASP.Net Core - Part 2

In the first article in this series, I've made a empty ASP.Net Core project with MVC 6 set up and ready to go.

In this article, I'll be looking to copy content from my existing ASP.Net MVC 5 project.

Steps I missed

I'm using pre-release libraries (pretty much everything) - but I forgot to set the Include Pre-release checkbox on the NuGet Package Manager. Oops.

I missed adding _ViewStart.cshtml - without this I wasn't getting the layouts pulled in.


So these are the steps for this article that I've taken:

One thing you will notice is that bundling & minification has disappeared. We are going to use Gulp for these, but to keep this article simple I'll set that up in the next article.

Tag Helpers

"Tag Helpers are a new feature in MVC that you can use for generating HTML. The syntax looks like HTML (elements and attributes) but is processed by Razor on the server. Tag Helpers are in many ways an alternative syntax to Html Helper methods but they also provide some functionality that was either difficult or impossible to do with helper methods." MSDN

In my case, I've replaced:

@Html.ActionLink & @Url.Action


<a asp-action="Index" asp-controller="Home" ...

Definitely looks a lot cleaner in the HTML.


In RC1 it appears that Html.RenderPartial hasn't been implemented.

Apparently sorted in in RC2 (see this stack overflow answer).

For now, we just amend to Html.RenderPartialAsync.


I use less for my CSS. ASP.Net Core moves you towards using a build tool to compile your less file to css.

This seems to be aimed at producing better tooling for Continuous Integration pipeline.

The two favourites seem to be Gulp and Grunt.

Both are NPM (node) based build tools and can accomplish much the same tasks. In my case I'm likely to use the build tool for compiling less to css, TypeScript to JavaScript, minification, bundling, etc.

So which tool to go for?

A quick read of comparisons on the internet indicate that there is a lot of parity between the two. Ultimately it seems that your main choice is between configuration (Grunt) and code (Gulp). Being a developer at heart, Gulp is my first choice.

For this article, all I need it to do is compile my less files. For this:

Add NPM Configuration (package.json). To which add the following the devDependancies:

Add the gulpfile.js - see the check-in for the basic setup

This seemed enough to get me going. This article talks you through using Gulp.


Ok, at this point I'm able to compile and run the website. All looks file. You can see it in this commit


In the next article I'm going to look at using more Gulp goodness to minify and bundle.

About the author:

Mark Taylor is an experience IT Consultant passionate about helping his clients get better ROI from their Software Development.

He has over 20 years Software Development experience - over 15 of those leading teams. He has experience in a wide variety of technologies and holds certification in Microsoft Development and Scrum.

He operates through Red Folder Consultancy Ltd.