Microsoft.Aspnetcore.Authorization namespace is missing with .NET Core 2.2
Microsoft.Aspnetcore.Authorization namespace is missing when using .NET Core 2.2
To Reproduce
- Set TargetFramework of .csproj file to "netcoreapp2.2"
- Set RuntimeFrameworkVersion to "2.2.0"
- Include PackageReference "Microsoft.AspNetCore.App"
- Try to use Authorize attribute or to Microsoft.AspNetCore.Authorization namespace in any controller.
- Namespace is not found.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<RuntimeFrameworkVersion>2.2.0</RuntimeFrameworkVersion>
<DebugType>Full</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App"/>
</ItemGroup>
</Project>
Expected behavior Running the same project with net core 2.1 works fine. Tried to include Microsoft.AspNetCore.Authorization package explicitly using nuget with no success. Error appears to be the same.
Screenshots

Desktop:
- OS: Windows 10 x64
- IDE: Visual Studio 15.9.3
I've the same series of issues - with that namespace, and more.
I've postponed our update for now. We really wanted to the supposed HTTP performance improvements in Linux, but it'll have to wait.
I am having this same issue.
Relevant parts of .csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.0" />
</ItemGroup>
</Project>
Here is the error I am seeing when I try to include the namespace in a Controller:

Just checking - have you installed the ASP.NET Core 2.2 runtime and SDK via the installer? You can find the .NET Core installers here: https://dotnet.microsoft.com/download
ASP.NET Core requires both NuGet packages as well as runtime libraries that are installed separately.
Eilon, I did use two separate installers on that page. My app will run, I have DI setup, routing, and controllers+views are working.
I was able to get the Authorization package to work using an odd set of steps that may have just been a coincidence. I set the netcoreapp version back to 2.1, which caused my project to throw a bunch of errors. I then edited my .csproj and put in the reference to Microsoft.AspNetCore.Authorization. I tried to rebuild the solution, and there were still a bunch of errors. I then switched the netcoreapp setting back to 2.2, and I was able to rebuild the solution successfully. I can now reference Microsoft.AspNetCore.Authorization in my controllers and use the [Authorize] decorator.
I just had this same exact issue pop-up again, but this time with the Microsoft.AspNetCore.Authentication.Cookies package.
I installed this package to my project using Install-Package Microsoft.AspNetCore.Authentication.Cookies -Version 2.2.0. After doing that, I still could not reference it in my project. When I highlighted the dependency in my project and looked at the properties, I saw the Path for that package was set to C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.cookies\2.2.0
I went in and removed the entire folder C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.cookies and then did a package restore in VS. After doing this, I noticed it updated the Path to C:\Users\<my user name>\.nuget\packages\microsoft.aspnetcore.authentication.cookies\2.2.0.
I then rebuilt the project and everything worked. I can now reference Microsoft.AspNetCore.Authentication.Cookies.
I would not be surprised if this was the same issue.
Thanks for the extra info @jonnale . It's not clear to us the exact cause for this but if anyone has exact steps to reproduce this problem, please upload your project to a GitHub repo with instructions on what to install, what to run, etc., and we can try to investigate more. In the meantime I'm closing this issue because there's no immediate action for us to take here.