0% found this document useful (0 votes)
2 views4 pages

Conventional Routing Task

The document outlines three tasks for configuring routing in ASP.NET Core applications. Task 1 involves setting up a default MVC route, Task 2 adds a custom route with parameters and constraints, and Task 3 configures multiple named routes with specific ordering and constraints. Each task includes steps for creating new projects and testing URLs to ensure proper routing functionality.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Conventional Routing Task

The document outlines three tasks for configuring routing in ASP.NET Core applications. Task 1 involves setting up a default MVC route, Task 2 adds a custom route with parameters and constraints, and Task 3 configures multiple named routes with specific ordering and constraints. Each task includes steps for creating new projects and testing URLs to ensure proper routing functionality.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Task 1 (Easy): Default conventional route

Goal: Wire up MVC and a default route /{controller=Home}/{action=Index}/{id?}.

Steps:

1. Create project: [Link] Core Empty → ConvRoutingTask1.


2. Add MVC:
Task 2 (Moderate): Custom route with parameters +
constraint
Goal: Add a second route before default: products/{category}/{id:int?}

Steps:

1. New project: ConvRoutingTask2 (Empty).


2. [Link]:
Test URLs:

 /products/laptop → category=laptop, id=null


 /products/mobile/25 → category=mobile, id=25
 / → Default Home/Index
 Try /products/mobile/abc → 404 (id must be int)

Task 3 (Complex): Multiple conventional routes (admin +


blog with constraints)
Goal: Configure three named routes with ordering/precedence:

 admin/{action=Dashboard} → AdminController
 blog/{year:int:min(2000)}/{month:int:range(1,12)}/{slug?} →
[Link]
 Default route fallback

Steps:

1. New project: ConvRoutingTask3 (Empty).


2. [Link]:

You might also like