There are a few gotchas when migrating Visual Studio 2015’s ASP.NET 5 web application template from
This quick guide will help you through them.
First of all, at the time of writing
Applicaiton Insights has no
RC2 equivalent. If you try to force the reference in
RC2, you’ll see something like this:
To this end, remove all references to
Application Insights from your app.
First up, remove even the reference to
Application Insights from your
project.json, deleting the line shown below:
Now compile the app and run through any compilation errors that arise due to the now removed
Application Insights reference.
You should find some references in
Startup.cs. Remove all the below, if you find them, and any other references that might be in there (in case the template changed since the time of writing):
Next up, some sneaky references still reside in some cshtml files. Delete the following lines where
ApplicationInsights is in red:
_ViewImports.cshtml has one other sneaky change in
RC2 that we need to make. The line beginning with
@addTagHelper needs to have the quotes removed from around
*, Microsoft.AspNet.Mvc.TagHelpers, so it ends up looking like this:
The red squiggly error line is fine. Ignore it. It just wants to scare you but its behind a screen, it can’t touch you.
Run a find and replace on all cshtml files, replacing:
You can quite safely run a
Fine and replace throughout your solution like this:
ASP.NET 5 allows you to write funky code like this:
This particular example ensures that in developer environments, you see useful exceptions, whereas elsewhere you see friendly error pages.
For this to work in
RC2, you’ll need to add a new environment variable to be sure your
Development. Go to your project properties, click on the
Debug tab and add an
Environment Variable called
ASPNET_ENV with a value of
Finally, RC2 expects a
hosting.json file to be in the root of your project. This file configures how your application will be hosted. Create a file with that name and the following contents:
hosting.json will use Kestrel to serve your app, as you can see.
Now your application should run as expected. Enjoy!