Book Image

ASP.NET Core 2 Fundamentals

By : Onur Gumus, Mugilan T. S. Ragupathi
Book Image

ASP.NET Core 2 Fundamentals

By: Onur Gumus, Mugilan T. S. Ragupathi

Overview of this book

The book sets the stage with an introduction to web applications and helps you build an understanding of the tried-and-true MVC architecture. You learn all about views, from what is the Razor view engine to tagging helpers. You gain insight into what models are, how to bind them, and how to migrate database using the correct model. As you get comfortable with the world of ASP.NET, you learn about validation and routing. You also learn the advanced concepts, such as designing Rest Buy (a RESTful shopping cart application), creating entities for it, and creating EF context and migrations. By the time you are done reading the book, you will be able to optimally use ASP.NET to develop, unit test, and deploy applications like a pro.
Table of Contents (14 chapters)

Introduction to Routing


The routing engine is responsible for getting the incoming request and routing that request to the appropriate controller based on the URL pattern. We can configure the routing engine so that it can choose the appropriate controller based on the relevant information. In other words, routing is a programmatic mapping that states which method of which controller is to be invoked based on some URL pattern.

By convention, ASP.NET MVC follows this pattern: Controller/Action/Id.

If the user types the URL http://yourwebsite.com/Hello/Greeting/1, the routing engine selects the Hello controller class and Greeting action method within the Hello controller, and passes the Id value as 1. XXXController is a naming convention and it is assumed your controllers are always ending with a controller suffix. You can give default values to some of the parameters and make some of the parameters optional.

The following is the sample configuration:

The template: "{controller=Hello}/{action...