Caverman
Caverman

Reputation: 3707

.Net Core 3 console app no Startup class or Appsettings?

Obviously I'm still new with .Net Core with this question so bare with me. I created a .Net Core Console Application through Visual Studio 2019 and it did not create a Startup.cs class automatically. All it created was Programs.cs file. From what I understand and reading there has to be a Startup class since it is effectively the Global.asx file in .Net framework.

First I want to make sure I didn't miss a step that would have created the Startup automatically? Second, I'm assuming I can copy the code out of one of my test MVC Core applications and just use that?

Same question with Appsettings.json, I'm assuming I can just copy one from another project?

Upvotes: 1

Views: 2685

Answers (2)

Manoj
Manoj

Reputation: 57

  1. you didn't miss anything. when you create a console application then there no need for Startup.cs file.
  2. If you want to create a web application then Startup.cs file is necessary because it's called by Program.cs file.
  3. The main method will execute in both the application. eighter it is a console or web application. the main method is the entry point from where your application will start.
  4. Now if u r confused to take Startup.cs file it's for configuring various middleware for the web application that will be available during you will HTTP request from your browser.
  5. if you are confused to take appsetting.json this is the only configuration file that you can copy from any application to any application. but you will need to take care of what configuration you have done in it.

Upvotes: 0

Prasad Telkikar
Prasad Telkikar

Reputation: 16049

When you create .net core console application then your entry point will be Program.cs file Main() function

When you create MVC application in .net core then it creates StartUp.cs file as an entry program and application.json file for configuration.

Console application does not create both files for you.

Upvotes: 1

Related Questions