Updating a Visual Studio 2015 template ASP.NET 5 web application from RC1 to RC2
• blog
There are a few gotchas when migrating Visual Studio 2015’s ASP.NET 5 web application template from RC1
to RC2
.
This quick guide will help you through them.
Application Insights
First of all, at the time of writing Applicaiton Insights
has no RC2
equivalent. If you try to force the reference in project.json
to RC2
, you’ll see something like this:
To this end, remove all references to Application Insights
from your app.
project.json
First up, remove even the reference to Application Insights
from your project.json
, deleting the line shown below:
Code
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):
cshtml
Next up, some sneaky references still reside in some cshtml files. Delete the following lines where ApplicationInsights
is in red:
\Views\Shared\_Layout.cshtml
\Views\_ViewImports.cshtml
_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.
All cshtml
Run a find and replace on all cshtml files, replacing:
asp-validation-summary="ValidationSummary.All"
With:
asp-validation-summary="All"
You can quite safely run a Fine and replace
throughout your solution like this:
Development mode
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 env
is Development
. Go to your project properties, click on the Debug
tab and add an Environment Variable
called ASPNET_ENV
with a value of Development
:
hosting.json
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:
This hosting.json
will use Kestrel to serve your app, as you can see.
Now your application should run as expected. Enjoy!