C
C#2mo ago
textYash

Unable to add a new Controller in Visual Studio

I am trying to learn .NET. I created a new C# MVC project but I'm unable to add a new controller. I don't see any option for that. I asked Copilot and googled it but unlike they say, there is no "Controller" button under "Add" I'm using the Visual Studio Community Edition downloaded from the Microsoft Store
No description
17 Replies
Angius
Angius2mo ago
Add new item There you should have all the different scaffolding options
textYash
textYash2mo ago
I tried that but I can't find controller on there
textYash
textYash2mo ago
No description
textYash
textYash2mo ago
Where should I be looking here?
Angius
Angius2mo ago
Web
textYash
textYash2mo ago
but still no controller option
textYash
textYash2mo ago
No description
Angius
Angius2mo ago
Huh I'd just not bother and add write the controller myself tbh ¯\_(ツ)_/¯ Just to double-check though 1. Do you have the web worload installed with VS? 2. What's the version of .NET this project uses?
textYash
textYash2mo ago
what's web worload? I opened .csproj in notepad and it has
C#
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
C#
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
Angius
Angius2mo ago
When you run the Visual Studio Installer you can modify your VS installation
Pobiega
Pobiega2mo ago
VS isnt in project mode
Angius
Angius2mo ago
That's where you can install different workloads
Pobiega
Pobiega2mo ago
its in folder mode
Angius
Angius2mo ago
Ah The classic
Pobiega
Pobiega2mo ago
No description
Pobiega
Pobiega2mo ago
with VS, you need to open a solution or project file, not a folder
Angius
Angius2mo ago
So, yeah, close VS and open it by double-clicking the .sln file of your project Or .csproj should the sln not be there