■ Contents
xvii
Customizing the Routing System ................................................................................. 484
Changing the Routing System Configuration ......................................................................................484
Creating a Custom Route Class ..........................................................................................................486
Working with Areas ...................................................................................................... 497
Creating an Area ................................................................................................................................. 497
Creating an Area Route ....................................................................................................................... 498
Populating an Area ............................................................................................................................. 499
Generating Links to Actions in Areas .................................................................................................. 502
URL Schema Best Practices ......................................................................................... 503
Making Your URLs Clean and Human-Friendly ................................................................................... 503
GET and POST: Picking the Right One ................................................................................................. 504
Summary ...................................................................................................................... 505
■Chapter 17: Controllers and Actions ������������������������������������������������������������������ 507
Preparing the Example Project ..................................................................................... 508
Preparing the Views ............................................................................................................................ 509
Understanding Controllers ............................................................................................ 511
Creating Controllers ..................................................................................................... 512
Creating POCO Controllers ..................................................................................................................512
Using the Controller Base Class ......................................................................................................... 514
Receiving Context Data ................................................................................................ 516
Getting Data from Context Objects .....................................................................................................516
Using Action Method Parameters ....................................................................................................... 520
Producing a Response .................................................................................................. 522
Producing a Response Using the Context Object ................................................................................522
Understanding Action Results ............................................................................................................. 524
Producing an HTML Response ............................................................................................................ 526
Performing Redirections ..................................................................................................................... 535
Returning Different Types of Content .................................................................................................. 543
Responding with the Contents of Files ............................................................................................... 545