Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Avoid querying the ServerVariables collection

Total Hit ( 5645)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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:

Click here to copy the following block
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.



Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.