Route generate URL in MVC:-

In this section let’s discuss how Route engine generate the ULR based on request. We have helper methods like “Html.ActionLink” or “Url.Action” and both have to return the url. In MVC framework all generate url methods are directed to call the one of the “GetVirtualPath” method in “RouteCollection” class.

       
public VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values);
        
public VirtualPathData GetVirtualPath(RequestContext requestContext, string name, RouteValueDictionary values);

    
    
  • requestContext - object that encapsulates information about the requested route
  • values - object that contains the parameters for a route specified by user
  • name – name of the route to use when information about the URL path is retrieved

Let’s understand the url generation process using flow chart as mention below