Table of contents
2. C# .NET WEB program structure
1. Demo
1. Create a project
The created project structure is as follows:
Properties |
Configuration file, which stores some .json files for configuring ASP.NET Core projects |
Propertics/launchSettings.json |
The startup configuration file is used for the startup preparation of the application, including environment variables, development ports, etc. |
Program.cs |
Contains the Main method of the ASP.NET Core application, which is responsible for configuring and starting the application |
Startup.cs |
Entry startup file for ASP.NET Core project |
The project also creates two files by default: WeatherForecast.cs and Controllers.WeatherForecastController.cs.
WeatherForecast.cs is equivalent to an entity class with four attributes:
Controllers.WeatherForecastController.cs is equivalent to the controller in MVC:
2. Start the project
Start the project with default configuration:
Effect: access the [HttpGet] method by default
Specify an access path to the Get method:
3. Write api demo
Create a new api file (controller controller)
The created template is as follows:
create an interface
Change the default startup path
Start the project, access the interface
Reference 1: ".NET CORE takes you to do projects" 2. Create the first API project
Reference 2: Basic project directory structure of .NET Core 2.1
2. C# .NET WEB program structure
The C# structural form of MVC: