Looking inside the urlMapping
I see that the mappedUrl
are store on UrlMappingCollection
that come from ConfigurationElementCollection that virtual have no limits.
The number of urls.
I think that virtual there is no limit on how many you can load.
The load time
The load delay is only on the stating the web, then its keep on a static value, and reloaded only when you change the web.config, or restart the app.
The Memory
Well you have a static collection with all that data called on the start of every request. Depends how many data you going to load on web.config.
The search time
The search time, from my research is not done using any hash method, but they compare the strings together one by one, so here maybe we have a small issue.
This is the code with the heavy search for every url
internal string HttpResolveMapping(string path)
{
string mappedUrl = null;
string str2 = UrlPath.MakeVirtualPathAppRelative(path);
UrlMapping mapping = this.UrlMappings[str2];
if (mapping != null)
{
mappedUrl = mapping.MappedUrl;
}
return mappedUrl;
}
here the UrlMapping mapping = this.UrlMappings[str2]; is calling the
protected internal ConfigurationElement BaseGet(object key)
{
foreach (Entry entry in this._items)
{
if ((entry._entryType != EntryType.Removed) && this.CompareKeys(key, entry.GetKey(this)))
{
return entry._value;
}
}
return null;
}
I need to check it a little more, but I think there is an issue on search for the url mapping.
In Real Life
Recently I optimize similar code for database calling. I get down the speed from 500ms to 150ms-200ms on a similar loop that is called 20.000-50.000 times in few seconds.
In your case I do not think that this routing is going to called more than 100-200 times in a page call. (and I say 100 because you redirect all call to asp.net, even the images)
So I think that is really depend for how super fast you won your web to be, but the users of you I do not think that they note the different, and on this point you only going to gain 10-20-30ms faster - and we speak only if you have huge amount of urls (maybe more than 1500 urls).
Also the first page with the content is called, then search from this loop, return the page, then the images follows, so the user is going to see the different only on the first 1-5 calls delay of the page and did not understand the small delay on the images.
The optimization here is only going to be measured on programs and not be understand by the users.
The times here is from my experience on my (slow) computers and is to give only the sense of my experience.
Some more words
I think that urlMapping is a ready to go solution that can help anyone to start with, but if some have the time the knowlege and the resource is worth to fix his own url mapping, make it in his needs and super fast if hes like. For start is good to have urlMapping but if you need some more advanced thinks, then you can update it later when your project go bigger.
I am fan of the speed, every second that wait on the computer is a second from our life.
How ever if it easy for you to use the urlMapping just do it, make the site workable, and then you check it again after some months.