Cheap ASP.NET Core 1.0 Hosting Tutorial – How To Create ASP.NET Core 1.0 RC2 App From Scratch

Cheap ASP.NET Core 1.0 Hosting Tutorial – How To Create ASP.NET Core 1.0 RC2 App From Scratch

CheapASPNETHostingReview.com | Cheap and reliable ASP.NET Core 1.0 RC2 hosting. In this post I will show you how to create ASP.NET Core 1.0 RC2 App from Scratch.

So the first things that you have to do is install RC2

If you haven’t already, install Preview 1 tooling for Microsoft .NET Core 1.0.0 RC2
https://visualstudiogallery.msdn.microsoft.com/c94a02e9-f2e9-4bad-a952-a63a967e3935?SRC=VSIDE

Then create your web app

Open up Visual Studio and select File > New > Project.  If you have Core 1 RC2 installed you should see and exciting new category under Templates > Visual C#  called .Net Core!

c1

Select “ASP.NET Core Web Application”, give it a name, and click “OK”.

Setup Project.json

Open up your project.json file. This will be new to you if you haven’t played with previous releases of vNext.

To create a basic MVC app you will need to add the following dependencies to project.json:

  • “Microsoft.AspNetCore.Mvc”: “1.0.0-rc2-final”
  • “Microsoft.AspNetCore.StaticFiles”: “1.0.0-rc2-final”
  • “Microsoft.Extensions.Configuration.FileExtensions”: “1.0.0-rc2-final”
  • “Microsoft.Extensions.Configuration.Json”: “1.0.0-rc2-final”
  • “Microsoft.Extensions.Configuration.EnvironmentVariables”: “1.0.0-rc2-final”

And you will need to make sure “buildOptions: preserveCompilationContext” is set to true. After making these changes, your project.json should now look like this:

Save and compile the project.json file and you should see that these packages have been added to your project’s references.

c2

Add the  ASP.NET Cofiguration file

Right-click your project > Add New… > Select new ASP.NET Configuration File and name it appsettings.json

c4

Setup Startup.cs

The Startup.cs file will look the same as it did in RC1.  The 3 main things we will change for our basic example application are the following:

  • Add a Startup() constructor method and link it to appsettings.js
  • Add the MVC service to ConfigureServices()
  • Configure the MVC the default routes (this replaces the old route config file) and tell the app to use static files in Configure()

After the above changes have been made, your Startup.cs should now look like this:

Lastly, add your Controllers and Views

Right-Click your project and add 3 new folders.

  • Controllers folder
  • Views folder
  • Home folder, inside of the Views folder

Next, right-click the Home folder and add a new MVC View Page. Name it “Index.cs” and add some “Hello World” text to it.

After adding these folders and file, your project will now look like this:

c3

Finished!!!!

Check out the final project on GitHub
Build and run your application.  Congrats on keeping up with the cutting edge of .Net