Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VBS,IIS4,IIS5
Expertise: beginner
Sep 23, 2000

Avoid querying the ServerVariables collection

You can access a lot of useful information through the ServerVariables collection, but this has a price in terms of performance. More precisely, the first time you reference this collection in a page, IIS must collect all the data that is necessary to create the collection. All the subsequent references come for free, however.

In some cases you can substitute a reference to a server variable with a constant value. For example, many developers use the LOCAL_ADDR, SERVER_PORT, and PATH_INFO server variables to dynamically build a path relative to the current page or the domain that hosts the page:


fullurl = "http://" & Request.ServerVariables("LOCAL_ADDR")
    & ":" & Request.ServerVariables("SERVER_PORT")
   & Request.ServerVariables("PATH_INFO")
However, these values vary infrequently, so you should consider using constant strings instead. If you want to build a page that works correctly regardless of the domain it runs under (which is especially useful to debug the page before uploading to the real Internet server) you can store the domain path in an Application variable in the Application_OnStart procedure in GLOBAL.ASA.
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap