What is MVC Routing


Allows for navigation by entering a URL into a browser, mapping the browser request to the controller action, and ultimately returning the corresponding page.

What is MVC Routing

Written by: Dominic Wegrzynowski Oct 04, 2023

MVC Routing allows for navigation by entering a URL into a browser, mapping the browser request to the controller action, and ultimately returning the corresponding page. Default MVC routing is based upon the pattern "Controller/Action/ID".

Example: localhost:1234/{controller}/{action}/{id}

Controller: is the controller that handles the request

Action: is the action method in the controller

Id: This is optional, but when present can be used to query data

For instance, in my Bugtracker MVC application, the Ticket Details page displays a single ticket's information. All of the information necessary to display this page is found in the browser request URL. The Tickets/Details/3 route will have the Details action of my Tickets Controller to query the database for the ticket with an Id of 3 and if it's found return that ticket as the Model to the View where its information is displayed in the requesting browser.


Tags

Login to add a comment
0 COMMENT(S)