I have an older ASP.NET Core Web API developed in Visual Studio 2017, targeting .NET Framework 4.5.2 and utilizing Microsoft.AspNetCore 1.1.2 and Microsoft.AspNetCore.Mvc 1.1.3.
In that project, I have a controller method that returns an IActionResult with lines like this, which work fine:
Similar to the discussion here:
I am currently creating a new web API in VS 2017 targeting .NET Framework 4.6.1 and ASP.NET Core 2.0, using Microsoft.AspNetCore 2.0.1 and Microsoft.AspNetCore.Mvc 2.0.2. In this new project, the same lines have a compilation error.
CS0103 The name 'Unauthorized' does not exist in the current context
VS provides recommendations to change these to:
Was this a breaking change made in Core 2.x? Or am I missing a package or dependency in my new project? If I use UnauthorizedResult(), I get an error that it cannot be used like a method.
If this is a change, I can't seem to find any documentation about it.