Using the HTTP Method Selector Attributes
The routing system provides the MVC framework with details of which controller and action are targeted by a requested URL. These are the values assigned to the controller
and action
routing variables.
The MVC framework can figure out which class corresponds to the requested controller pretty easily (although it does sometimes need some help when areas are used, as I explained in Chapter 27). Working out which method the action corresponds to is more complicated, because C# allows us to create multiple methods of the same name but with different parameter signatures. Listing 28-22 shows a new controller class, called Reports
, that I have added to the example project and that contains two methods called ...
Get Applied ASP.NET 4 in Context now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.