No Controllers menu item on the Asp.net core 5.0 Web API project

Sampath Lokuge 21 Reputation points
2021-04-22T11:32:43.353+00:00

Hi,

Microsoft Visual Studio Community 2019 Version 16.9.4 Windows 10 Pro

Any clue why I cannot see the Controllers menu item? This is the Asp.net core 5.0 Web API project

MS Doc says this: https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-5.0&tabs=visual-studio#scaffold-a-controller

But I cannot see that?

Stackoverflow: https://stackoverflow.com/questions/67201201/no-controllers-menu-item-on-the-asp-net-core-5-0-web-api-project

CinamaApi.csproj

<Project Sdk="Microsoft.NET.Sdk.Web">  
  
  <PropertyGroup>  
    <TargetFramework>net5.0</TargetFramework>  
  </PropertyGroup>  
  
  <ItemGroup>  
    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />  
  </ItemGroup>  
  
  <ItemGroup>  
    <Folder Include="Controllers\" />  
  </ItemGroup>  
  
</Project>  

90333-2.png

90334-3.png

Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 60,326 Reputation points
    2021-04-22T14:19:06.847+00:00

    Hmm. It seems like the project file is correct but the IDE isn't synced properly with it. Have you restarted VS to ensure the solution view is synced? Things that can also get in the way include being in "folder view" in Solution Explorer and not having the solution actually open. If you can debug the project then that is not the case here.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Duane Arnold 3,216 Reputation points
    2021-04-22T16:11:40.497+00:00

    Of course one knows that .NET 5 is .NET Core. So you would have had to select a .NET Core Web project in order to get things to show correctly in the VS IDE using .NET 5.

    Also, if adding a new controller, one would right-click on the Controller folder, Add new Item and Controller would be the first item that one can select above 'New Item' menu item without having to go into selecting an item in the list of items that are selectable for the project.

    Maybe, you're not using a Core project, but somehow, you have selected .NET 5 that is .NET Core?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.