Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How RouteTable which get assigned route collection in Application_Start maintain its values

I have doubts about how routing mechanism work in mvc since as we can see in Application_start we see code

    RouteConfig.RegisterRoutes(RouteTable.Routes);   

but as i have debugged into Source Code this function extension method and it is not assigning route collection to any context object. below is few lines of that source code.

since created route collection is not getting assigned to any application level object how it is possible that framework detect these routes and handle request according to URL mentioned in collection. that collection should get vanish right?

and please guide me where i can get exact working of MVC framework and how data shared between application objects.

    public void Add(string name, RouteBase item)
    {
    if (item == null)
    throw new ArgumentNullException(nameof (item));
    if (!string.IsNullOrEmpty(name) && this._namedMap.ContainsKey(name))
    throw new ArgumentException(string.Format((IFormatProvider) 
    CultureInfo.CurrentUICulture, 
    System.Web.SR.GetString("RouteCollection_DuplicateName"), new object[1]{ 
    (object) name }), nameof (name));
    this.Add(item);
    if (!string.IsNullOrEmpty(name))
    this._namedMap[name] = item;
    Route route = item as Route;
    if (route == null || route.RouteHandler == null)
    return;
    TelemetryLogger.LogHttpHandler(route.RouteHandler.GetType());
    }

    private Dictionary<string, RouteBase> _namedMap = new Dictionary<string, 
    RouteBase>((IEqualityComparer<string>) 
    StringComparer.OrdinalIgnoreCase);
    private ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim();

Comments