Introduction to ASP.NET Core
Welcome to the official Microsoft documentation for ASP.NET Core. This section provides a comprehensive guide to building modern, cross-platform web applications and services with .NET.
What is ASP.NET Core?
ASP.NET Core is a free, open-source, cross-platform framework for building modern, cloud-based, internet-connected applications. It is a rewrite of the ASP.NET platform, designed to:
- Be faster and more performant.
- Be modular and extensible.
- Support cross-platform development (Windows, macOS, Linux).
- Enable cloud-native applications.
- Support a wide range of application types, including web apps, APIs, real-time applications, and microservices.
Key Concepts
Understanding these core concepts is crucial for developing with ASP.NET Core:
- Middleware Pipeline: ASP.NET Core applications are built around a pipeline of middleware components. Each component can process incoming HTTP requests and outgoing HTTP responses.
- Request Delegate (Delegate): A function that processes an HTTP request. Middleware components are chained together to form the request pipeline.
- Dependency Injection (DI): ASP.NET Core has built-in support for DI, making it easier to manage dependencies and create loosely coupled applications.
- Configuration: ASP.NET Core provides a flexible configuration system that supports various sources like JSON files, environment variables, and command-line arguments.
- Hosting: The `IHost` and `IHostBuilder` are responsible for setting up and running your ASP.NET Core application, including managing its lifecycle and services.
- Kestrel: A cross-platform web server built by the .NET Foundation, used by default to host ASP.NET Core applications.
Getting Started
To start building with ASP.NET Core, you'll need the .NET SDK installed. Here's a basic overview of creating your first application:
1. Create a New Project
You can use the .NET CLI to create a new web application:
dotnet new webapp -o MyAspNetCoreApp
cd MyAspNetCoreApp
2. Run the Application
Navigate into the project directory and run the application:
dotnet run
This will start the Kestrel web server, and you can access your application by navigating to the URL provided in the console output (usually https://localhost:5001
or http://localhost:5000
).
3. Project Structure
A typical ASP.NET Core web application project will have files and folders like:
Program.cs
: Entry point of the application, configures the host and the request pipeline.Pages/
orControllers/
: Contains Razor Pages or MVC controllers and views.wwwroot/
: Contains static files (CSS, JavaScript, images).appsettings.json
: Application configuration settings.
Core Features
- Razor Pages: A page-focused model for building dynamic web UI.
- Model-View-Controller (MVC): A well-established pattern for building complex web applications.
- Web APIs: Easily create HTTP services that can reach a broad range of clients.
- Blazor: Build interactive client-side web UI with .NET.
- SignalR: Add real-time web functionality to your applications.
- Authentication and Authorization: Robust support for securing your applications.
- Cross-Platform Compatibility: Deploy to Windows, macOS, Linux, and cloud platforms.
Next Steps
Explore the following resources to deepen your understanding and skills:
- Working with Razor Pages
- Building Web APIs with ASP.NET Core MVC
- Introduction to Blazor
- ASP.NET Core Fundamentals
For detailed API information, please refer to the ASP.NET Core API Reference.