Introducing Asp.net core to new developers

chuksel95

Jeromé

Posted on February 15, 2021

Introducing Asp.net core to new developers

BASICS

◇ Building block: The building block of every asp.net application is divided into 2 major layers : The runtime/infractures to hold the application and the code to run the application.
Under the runtime/infrastructure we have:

• Operating system: this is either the Windows, Mac or Linux OS of your local machine.
• Webserver: This is either the IIS, kestrel or docker webserver. They take the client request from the OS and send them to the appropriate app runtime.

• .Net runtime: This is where the .Net core application runtime sits. It comes automatically with the .net core SDK, and primarily provides infrastructure to run an existing code.
Under the code layer we have:

• .Net and third party libraries: These codes are auto generated, and provide primitive types that supplement your code.
• Application code: This is your own developed code that gives identity and purpose to the application.

◇ Creating a project

To create a project using visual studio You go to create new project 》asp.net core web application 》empty template.
Asp.net core scaffolds some basic codes to help u get started. An example of these codes is the startup.cs class. This is the entry point of the application, and contains methods to setup the application.

◇ Responding to HTTP requests.

Asp.net core makes use of middleware to process incoming http requests. These middlewares are functions registered in the configure() method of the startup.cs class. Each request entering the webapp request pipeline is passed from one middleware to another in the order in wish they are registered. An example of a middleware function is app.Usemvc()

◇ Serving static files.

Static files include html,css files. Static files are stored in a folder in the solution called wwwroot. For asp.net to serve a static file,a middleware which is app.UseFileserver() is registered.

◇ Error handling.

Asp.net core displays the developer exception page when an error or exception is thrown. To display a more user friendly page on the browser in production mode, we add a middleware, app.UseExceptionHandler(), which takes a parameter that maps to the error page to display for the user.

💖 💪 🙅 🚩
chuksel95
Jeromé

Posted on February 15, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related