Asp.NET Core

Finally the day has come. My ISP SmarterAsp.Net has enabled Asp.Net Core. When I saw this great news, I jumped into action and started converting my MVC 5 sites into Core.

The first lesson I learned was the server my sites were on was not upgraded. So I put in a ticket and had them move my account to an updated server.

I updated my Cosmic Coder site first. I did this site using an empty solution that simple calls a single static file; index.html. I learned a few things about caching and and site speed when I tested the site using WebPageTest.Org. I ended up adding the following to get the cache working;

                             app.Use(async (context, next) =>
                context.Response.Headers.Add("Content-encoding", "gzip");
                context.Response.Body = new System.IO.Compression.GZipStream(context.Response.Body,
                await next();
                await context.Response.Body.FlushAsync();

Next, was on to the Kenl.Net site. This is a highly tweaked data driven site. The first thing I did was get the layout page and the home page done. This time instead of using models, I used WebApi and Jquery to deliver the data.

On the front page, I use Jquery.Rss to retrieve the RSS feeds from Microsoft. I use JQuery to retrive the data from an Api to get data out of my database. I did not want to recreate my database so I did a code first existing database to get the data. This was a simple call;

Scaffold-DbContext ",1433;Database=DB_1233456_Blog;User Id=DB_123456_Blog_admin;Password=MyPassword;" Microsoft.EntityFrameworkCore.SqlServer
This made all the domain models and db context. The only issue was the classes were created in the root of the project. I had to create folders and move the files.

Luckily, I was able to copy and reuse most of the code I used in the MVC5 version in the new Asp.Net Core WebApi. After a few tweaks and a half hour or so, I was extracting data using Postman.

About 4 hours later, I was ready to upload the semi-completed project to SmarterAsp.Net.