হাসিব, আমি তোমার দেওয়া টেক্সটটিতে প্রয়োজনীয় মার্কডাউন ফরম্যাটিং, হাইলাইটিং এবং স্ট্রাকচার যোগ করে দিচ্ছি যেন এটি পড়ার জন্য একদম পরিচ্ছন্ন ও গোছানো হয়।

ASP.NET Core - True Ultimate Guide

Section 2: Getting Started - Notes

Installing Visual Studio Community and Logging In

1. Download Visual Studio Community:

  • Go to Visual Studio Downloads.

  • Click on the “Free Download” button for Visual Studio Community.

2. Install Visual Studio Community:

  • Run the downloaded installer.

  • Choose the required workloads (for ASP.NET Core development, select ”.NET desktop development” and “ASP.NET and web development”).

  • Click “Install” and wait for the installation to complete.

  • Create a New Outlook.com Email:

    • Go to Outlook Sign Up.

    • Click on “Create free account.”

    • Follow the prompts to set up a new email address.

  • Log In to Visual Studio:

    • Open Visual Studio Community.

    • If prompted, click “Sign In.”

    • Enter your new Outlook.com email and password.

    • Complete any additional sign-in steps if required.

Common Settings in Visual Studio

1. Editor Font:

  • Go to Tools > Options.

  • Navigate to Environment > Fonts and Colors.

  • Select Text Editor from the “Show settings for” dropdown.

  • Choose your desired font and size from the list.

2. Theme:

  • Go to Tools > Options.

  • Navigate to Environment > General.

  • Select your preferred theme from the “Color theme” dropdown (e.g., Dark, Light, Blue).

3. Word Wrap:

  • Go to Tools > Options.

  • Navigate to Text Editor > All Languages.

  • Check the box for Word wrap.

These steps should get you started with Visual Studio Community and help you configure the environment to suit your preferences.

Creating a New ASP.NET Core Empty Project

1. Open Visual Studio Community:

  • Launch Visual Studio.

  • Create a New Project:

    • Click on Create a new project.

3. Select Project Template:

  • In the search box, type “ASP.NET Core Empty”.

  • Select ASP.NET Core Empty and click Next.

4. Configure Your New Project:

  • Enter the project name (e.g., “MyFirstApp”).

  • Choose a location to save your project.

  • Click Next.

5. Additional Information:

  • Ensure .NET 7.0 (or the latest version) is selected.

  • Uncheck Configure for HTTPS.

  • Uncheck Enable Docker.

  • Click Create.

Explanation of the Code in Detail

C#

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();
  • var builder = WebApplication.CreateBuilder(args);

    • Purpose: Initializes a new instance of the WebApplicationBuilder class.

    • Details:

      • WebApplication.CreateBuilder(args): A static method that initializes a WebApplicationBuilder instance. args represents command-line arguments.

      • The builder sets up the default configuration, logging, and dependency injection (DI) services.

      • Configuration: Reads settings from various sources (e.g., appsettings.json).

      • Logging: Configures default logging services.

      • Dependency Injection: Registers services to be used by the application.

  • var app = builder.Build();

    • Purpose: Builds the WebApplication instance.

    • Details: Finalizes the app’s configuration, compiles middleware, and creates the WebApplication object that handles HTTP requests.

  • app.MapGet("/", () => "Hello World!");

    • Purpose: Sets up a route that maps HTTP GET requests to the root URL.

    • Details: app.MapGet matches GET requests. The lambda () => "Hello World!" defines the response.

  • app.Run();

    • Purpose: Runs the application.

    • Details: Starts the Kestrel web server and begins listening for incoming HTTP requests. This is a blocking call.

Kestrel Server and Reverse Proxy Servers

Kestrel Server

  • Overview: Lightweight, cross-platform web server for ASP.NET Core.

  • Responsibilities: HTTP request handling, hosting, and configuration (HTTP/2, HTTPS).

  • Use Case: Ideal for development.

Reverse Proxy Servers

  • Overview: Servers (e.g., Nginx, Apache, IIS) that forward client requests to backend servers.

  • Responsibilities: Load balancing, SSL termination, caching, and security (filtering, rate limiting).

  • Use Case: Used in front of Kestrel in production to enhance security and stability.

Explanation of ASP.NET Core Logs

Log TypePurpose
Listening onIndicates the URL and port where the app is accessible.
Application startedConfirms successful start and provides shut down instructions.
Hosting environmentSpecifies if it’s Development, Staging, or Production.
Content root pathShows the base path for application files.

These logs provide critical information about the state and configuration of your application, aiding in monitoring and troubleshooting.

Detailed Notes for launchSettings.json

launchSettings.json is a configuration file used to define settings for how the application is launched during development.

Structure:

  1. $schema: Provides IntelliSense and validation.

  2. iisSettings: Configures settings specifically for IIS Express.

  3. profiles: Defines different launch profiles (e.g., http, IIS Express).

JSON

"profiles": {
  "http": {
    "commandName": "Project",
    "launchBrowser": true,
    "applicationUrl": "http://localhost:5117",
    "environmentVariables": {
      "ASPNETCORE_ENVIRONMENT": "Development"
    }
  }
}

Summary

  • launchSettings.json configures development launch behavior.

  • It supports multiple profiles for different environments.

  • The iisSettings section specifically handles IIS Express parameters.

তুমি কি ASP.NET Core-এর এই সার্ভিসগুলোর কাজের ধারা বা আর্কিটেকচার আরও বিস্তারিত কোনো ডায়াগ্রামের মাধ্যমে বুঝতে চাও?