Results 1 to 3 of 3

Thread: IIS name

  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    IIS name

    This piece of code works fine:
    <pre><table id="Table1" height="20" cellSpacing="0" cellPadding="0" width="800" border="0">
    <tr>
    <td width="400" bgcolor=#584D78><%if (Request.ServerVariables("SERVER_NAME")=="comp-ap-AA") %>
    <font size="4" face="Arial" color=#FFFFFF> Test Server</font>
    <%else if (Request.ServerVariables("SERVER_NAME")=="comp-ap-BB") %>
    <font size="4" face="Arial" color= #FFFFFF> Development Server</font>
    <%else if (Request.ServerVariables("SERVER_NAME")=="comp-nlb-1") %>
    <font size="4" face="Arial" color= #FFFFFF> Live Server</font>
    <%else %>
    <font size="4" face="Arial" color= #FF0000> UNKNOWN Server</font>
    <%%>
    </td>
    </tr>
    </table>
    </pre>


    Well I say it works fine but say I am logged onto the server comp-ap-AA and I open my browser and type in http://localhost/index.asp where this code lives it comes up with UNKNOWN Server but if I type http://comp-ap-AA/index.asp it says Test Server for obvious reasons.

    The questions is, if I use http://localhost/index.asp from any server in the list how can it recognise if it is the test, development or live server?
    Jerry

  2. #2
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Hornsby Heights, New South Wales, Australia
    Posts
    3,822
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIS name

    Request.ServerVariables("SERVER_NAME") returns "localhost" if you run it on your localhost.

    Hence, change

    <%if (Request.ServerVariables("SERVER_NAME")=="comp-ap-AA") %>

    to

    <%if (Request.ServerVariables("SERVER_NAME")=="localhost") %>
    Cheers, Claude.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: IIS name

    <img src=/S/blush.gif border=0 alt=blush width=15 height=15> That makes sense..Thanks Claude

    Pretty obvious that localhost is called localhost <img src=/S/bash.gif border=0 alt=bash width=35 height=39>
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •