Kriya and Meditation for Software / IT Professionals. Conducted by Bipin Joshi in Thane. Read more...
Learn ASP.NET MVC, ASP.NET Core and ASP.NET Design Patterns. Courses conducted by Bipin Joshi on weekends. Click here for more details.

Install ASP.NET Core RC2 and Create "Hello ASP.NET Core" Application

If you are tracking the progress of ASP.NET Core 1.0 (formerly ASP.NET 5) you are probably aware that Microsoft has announced the availability of RC2. You can read detailed announcement here. This article aims at providing detailed instructions about installing the RC2 bits. Moreover, it quickly walks you through creating "Hello ASP.NET Core" web application.

Let's begin.

1. Uninstall ASP.NET Core RC1

This step is applicable only if you are currently running RC1 bits on your machine. If so, you need to uninstall ASP.NET RC1 first. Go to Add / Remove programs and locate ASP.NET RC1 entry to uninstall it.

I faced a tricky issue while uninstalling RC1 bits - the uninstaller asked for the original setup installable. So, you may consider having it ready with you. You can download the RC1 installer here.

Once you successfully uninstall the RC1 bits you will get a confirmation dialog like this:

2. Install ASP.NET Core 1.0 RC2

You can now install RC2 bits by following any of the ways outlined here. If you are a Visual Studio 2015 uses you have an easy way to install RC2 by running the Visual Studio 2015 MSI installer found here. Note that the Visual Studio MSI installer requires that you have Visual Studio 2015 Update 2 installed. So, make sure to update your Visual Studio 2015 to Update 2. The Update 2 can be found here.

The following figure shows the launching window of the MSI installer.

 3. Create a new ASP.NET Core 1.0 Web Application

If you worked with RC1, you will remember that the ASP.NET project templates and ASP.NET Core project templates were together in the template selected dialog. This has now changed. You have separate entries in the New Project dialog as shown below:

 

As you can see there are three entries now. The second and the third entries are for ASP.NET Core applications (depending on the target framework). Let's select the second entry that targets .NET Core 1.0.

The project template selection dialog now lists only those templates that are applicable to ASP.NET Core 1.0 as shown below:

Select Web Application and click OK to create the project.

4. Observe the project items in the Solution Explorer

Now that the project is created, have a look at the Solution Explorer. Although I am not going to enumerate the changes in this article you can read more about migrating RC1 applications to RC2 here.

Open various project items and notice a few things:

  • There is web.config added in the project root.
  • The Main() method is now moved inside Program.cs to make it inline with Console applications.
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();
    
        host.Run();
    }
  • Project.json now uses RC2 packages as illustrated in the following entries:
    ....
    ....
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    ....
    ....
  • The frameworks section now has different entires:
    "frameworks": {
      "netcoreapp1.0": {
        "imports": [
          "dotnet5.6",
          "dnxcore50",
          "portable-net45+win8"
        ]
      }
    }

5. Modify the Home controller and the Index view

Open HomeController from the Controllers folder and modify the Index() action as follows:

public IActionResult Index()
{
    ViewBag.Message = "Hello ASP.NET Core RC2 !!!";
    return View();
}

Here, you simply set a Message property on the ViewBag to "Hello ASP.NET Core RC2 !!!".

Now open the Index.cshtml from the Views > Home folder and remove all the HTML markup from it. Replace the markup with :

<h1>@ViewBag.Message</h1>

For this simple application this is what we want. So, enter t he above markup and save the Index view.

6. Run the application

Press F5 to run the application. If all goes well you will see the browser windows as shown below:

That's it! You just successfully installed ASP.NET Core RC2 and also developed a simple "Hello ASP.NET Core" application !!


Bipin Joshi is a software consultant, an author and a yoga mentor having 22+ years of experience in software development. He also conducts online courses in ASP.NET MVC / Core and Design Patterns. He is a published author and has authored or co-authored books for Apress and Wrox press. Having embraced the Yoga way of life he also teaches Meditation and Mindfulness to interested individuals. To know more about him click here.

Get connected : Twitter  Facebook  Google+  LinkedIn

Posted On : 17 May 2016


Tags : ASP.NET ASP.NET Core MVC .NET Framework C#