Free Resources from FMS

Additional Resources

 

Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.

Darren D.

 

Free Catalog

 

How to Display the Web Server Computer Name in an ASP Page

Provided by:  FMS Development Team

When you're working on a web site that uses two or more web servers in a server farm, it can be difficult to properly test your site because each page request can hit a different server. Deploying updates to the site means deploying your changes to every server in the farm. You want to make sure to test each server individually, and also test the load balancing solution employing the whole farm of servers. It would be convenient to display the web server name on every page, so you know for sure which server serves up your requests during testing.

Here's how you can display the server name on your web pages using an ASP script. It's really very simple. Just use this snippet of VBScript code in your ASP:

<%
  Set objWSHNetwork = Server.CreateObject("WScript.Network")
  Response.Write objWSHNetwork.ComputerName
%>

This code uses the Windows Scripting Host to access the computer name of the web server. It's a deceptively simple way to get this information. Before I found out about this method, I was moments away from writing a Visual Basic COM DLL to use the Windows API to get the computer name, install the DLL on every server in the web farm, and then write ASP code to call my VB component. Using the Windows Scripting Host is much easier, because it's built into Windows 2000 Server and you can easily utilize its power from an ASP page.

Return to the tips page