Monday, August 6, 2012

Faster HTTP_HOST / Host / Hostname

Just a side note, if you're developing a multiple-domains web application, it might be helpful to know that there's a faster way to get the hostname than using:


HttpContext.Current.Request.ServerVariables["HTTP_HOST"]


Try this if you've seen its a significant part of your execution:


HttpContext.Current.Request.Headers["Host"]


The reason for that is that ServerVariables is getting many more properties on initialization, including the headers.


No comments:

Post a Comment