Upon using dotnet new webapi -n API it produces the API folder with the properties, obj and bin subfolders as in the screenshot below, but it doesn't have a Controllers folder. Can anyone guide me on this? The project is using .NET 8.0
Why is 'dotnet new webapi' command not producing the controllers folder?
1.3k views Asked by haroon khan At
2
There are 2 answers
2
TP95
On
That command creates a Minimal API by default as shown here. A minimal web API does not have controllers.
Since the default for -controllers is false, entering dotnet new webapi without specifying the option creates a minimal API project.
To create a web API with controllers run the following command instead:
dotnet new webapi -controllers -n API
OR
dotnet new webapi --use-controllers -n API
Related Questions in .NET-CORE
- Repository manager receives the wrong connection string in .net core
- How can I overwrite the localization strings in a library
- Custom type resolution
- How to enable log to console Cosmos Client SDK requests
- Issue with Entity Framework Core: .Include() and .AsNoTracking() not displaying expected related entities
- Using Python CDK to bundle dotnet 8 code to AWS Lambda function
- How to make Visual Studio 2022 project launch Windows Terminal instead of PowerShell?
- Custom Metrics stop saving in App Insight after one hour
- How to send select input data for form submission?
- When I use built-in DockerFile in Visual Studio, I see no errors, but when I try to create image and container using terminal I get an error
- Failure to Execute the DBCommand: SQLite Err. 1 - C# / .NET / Entity Framework Core
- KeyCloak Handshake causing timeout
- problemas con los CORS en .net core 7 y angular 15
- Access Registed Scoped Services and Transient Services using GetService()
- .NET Core DB vs JSON model design
Related Questions in ASP.NET-CORE-WEBAPI
- Problem to upload several images per one request
- C# XML ModelBinding - ASP.NET Core 8 Web API - required field not found
- Dotnet Run is not working but the application is running in Visual Studio
- Xero authorization via ASP.NET Core 6 Web API
- Seeding user doesn't allow user to login in ASP.NET Core 8 Web API - endpoints do allow them to sign in
- I have created C# ASP.NET Core Web API - it shows default controller only (weather forecast) rest of the controller is not found
- EntityFrameworkCore.DbUpdateException: Unable to delete row, SQL Syntax error
- In clean architecture, is the presentation layer allowed to communicate directly with the infrastructure layer?
- Validating Access Token in ASP.NET Core Web API project
- ASP.NET Core Web API pipeline Does Not Work As expected
- C# ASP.NET Core Web API incorrectly returning 403 on remote server
- How do I bind List<object> using FromForm?
- ASP.NET Core 6 Web API : best way to pause before resending email
- Web API talking to Vue app hosted separately in IIS... why is app.use spa needed?
- High memory utilizing when fetch data from stored procedure to DataTable
Related Questions in DOTNET-CLI
- 401 error with .NET Web API when using dotnet run command but not in Visual Studio
- Is there a way to use dotnet command to determine the version number of the project build?
- Is it possible to specify and install dll packages alongside a dotnet cli tool?
- How to use dotnet CLI in CSharp code not through processes?
- Getting error "Unable to retrieve project metadata." when running dotnet ef dbcontext scaffold command
- How to use dotnet watch with release configuration and arguments passed to the application?
- How can .NET Core installer projects depend on the publish output?
- Can a csproj detect if using `dotnet` or `msbuild`/`devenv` for conditions?
- Why does the dotnet watch publish command not work after update?
- Why is 'dotnet new webapi' command not producing the controllers folder?
- Unable to install CSharpier globally with dotnet CLI
- Azure DevOps DotNetCoreCLI@2 test fails with coverlet total coverage
- .NET CLI installing SDK via global.json file
- Is there any "Analyze and Code Cleanup" tool for .NET project in VS Code or .NET CLI?
- C# project build fails in github action
Related Questions in .NET-8.0
- C# XML ModelBinding - ASP.NET Core 8 Web API - required field not found
- Which approach is right while creating a service for your update method?
- Can't open new instance of another window in my app, in WPF .NET 8
- New Blazor Web App, Password Reset "A valid antiforgery token was not provided"
- Dotnet Run is not working but the application is running in Visual Studio
- My Blazor UI is not responding on a domain, but working on another domain
- Seeding user doesn't allow user to login in ASP.NET Core 8 Web API - endpoints do allow them to sign in
- Get rid of Generated using the Generated using the NSwag toolchain v11.0.0.0 (Newtonsoft.Json v13.0.0.0)
- I'm trying to create a user with identity in .NET 8 with Entity Framework and I'm getting the following error, both in MySQL and SQL Server
- WPF Windows Initializing is locking the separated thread in .Net 8
- Entity Framework Core 8 throws "Method not found: 'Void CoreTypeMappingParameters..ctor" error
- Blazor DbContext in a service
- Nullability Mismatch Between Property Getter and Setter?
- Access Registed Scoped Services and Transient Services using GetService()
- ASP.NET Core 8 Web API with Swagger not running as localhost web app
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)

It seems to be a recent .NET 8 change resulting in the Minimal APIs used by default.
From the docs for dotnet new templates: webapi (with fixed typo - PR @github):
So add
-controllers/--use-controllersoption to the command to get controllers:Or