Rants and Raves

Thanks for visiting my blog!

Upgrading ASP.NET 5 Beta 8 to RC1
Upgrading ASP.NET 5 Beta 8 to RC1
December 26, 2024

UPDATED: Missed fixes.

It’s that time again. ASP.NET 5 has a new release and this one has a go-live license! As announced today, the RC1 is available and a new RC2 is coming in the future.

If you’re like me, you have a couple of Beta 8 apps that you’d like to get up to speed with the RC1. In this post I’ll share with you the changes that I’ve found that impacted me. This isn’t exhaustive. Lucky for us, Beta8 to RC1 seems like a small jump (unlike earlier posts).

Don’t forget to install the update for the RC1 for Visual studio:

https://get.asp.net

You’ll also want to make sure you get the latest version of the runtime by opening a console and typing:

dnvm upgrade

```csharp

### global.json

You may not have a global.json file. If you do, you’ll want to switch it to use the RC:


```xml
{
  "sdk": {
    "version": "1.0.0-rc1-final",
    "runtime": "clr",
    "architecture": "x86"
  },
  "projects": [
    "wrap"
  ]
}

Note that the suffix is rc1-final to be sure it’s the final version of RC1. If you don’t have a global.json file (or it’s hidden), you can specify it via the project properties, but its usually not necessary since the RC1 will be your default after installing those bits:

image

project.json

  • Start by find/replace all -beta8 with -rc1-final
  • If you’re using SQL Server, you’ll need to change the reference of **EntityFramework.SqlServer **to EntityFramework.MicrosoftSqlServer
  • Next, you’ll want to change the name of all the Microsoft.Framework.* references to Microsoft.Extensions.*.

For example:

  "dependencies": {
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.Core": "7.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Twitter": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", 
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.AspNet.Cors": "6.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Abstractions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-*",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
  },
  • The template has changed and now you don’t need certain elements in project.json (e.g. webroot, usersecrets) and you can trim them out if you wish. But no effect if you don’t create it.

startup.cs

  • If you’re using AddCookieAuthentication(…) to configure cookie authentication, you’ll need to move it from ConfigureServices down to Configure and change it to UseCookieAuthentication with the new lambda style options:
// Configure is called after ConfigureServices is called.
public  void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

    //...
    
    // Setup Cookie Authentication
    app.UseCookieAuthentication(options =>
    {
        options.AccessDeniedPath = new PathString("/Home/AccessDenied");
    });
  • Likewise if you’re using UseDatabaseErrorPage, you’ll want to switch to the lambda syntax options likewise:
app.UseDatabaseErrorPage(options =>
{
    options.EnableAll();
});
  • You’ll also want to add the entry point (it was generated for you but now it’s more obvious as the startup for the app:
public class Startup
{
    // ...

    public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}

```csharp

### An Important Fix

In beta-8, they switched to Kestrel for all the web hosting which exposed an error I talked about in the last of these posts. Essentially parameters were coming into controllers without being URL Decoded so that if I requested **/api/foo/bar%20quux**, the ‘**bar%20quux**’ wasn’t being decoded to ‘**bar quux**. That’s fixed!