Category: ASP.NET MVC

Showing all posts with category ASP.NET MVC

2025-04-23 15:12:04

Routing in ASP.NET MVC

Conventional routing: this sort of routing is defined by calling the MapRoute method, by setting its unique name, URL pattern, and a few default settings.

  • URL routing will consider the domain name. The URL pattern "{controller}/{action}/{id}" resembles localhost:1234/{controller}/{action}/{id}. 
  • The default controller and action method will be used to handle requests when the URL does not contain any more information following the domain name.
  • When ASP.NET MVC starts, it registers one or more patterns with the framework route table to tell the routing engine what to do with requests matching those patterns. When a request is received by the routing engine during runtime, it checks the URL against its URL patterns and returns the response.

 

Attribute-based routing is defined by specifying the Route attribute in the controller's action method.