Explain what is routing in MVC? What are the three segments for routing important?

Routing is a mechanism to process the incoming url that is more descriptive and give desired response. In this case, URL is not mapped to specific files or folder as was the case of earlier days web sites.

There are two types of routing (after the introduction of ASP.NET MVC 5).
  1. Convention based routing: to define this type of routing, we call MapRoute method and set its unique name, url pattern and specify some default values.
  2. Attribute based routing: to define this type of routing, we specify the Route attribute in the action method of the controller.
Routing is the URL pattern that is mappped together to a handler,rounting is responsible for incoming browser request for particular MVC controller. In other ways let us say routing help you to define a URL structure and map the URL with controller. There are three segments for routing that are important,
  1. ControllerName
  2. ActionMethodName
  3. Parammeter
i.e: ControllerName/ActionMethodName/{ParamerName} and also route map coding written in a Global.asax file.

Comments

Popular posts from this blog

What is the difference between “HTML.TextBox” vs “HTML.TextBoxFor”?

Explain what is the difference between View and Partial View?