Very strange Website behavior.

I’ve been developing a web site for months now. I am working in IIS. The site is all being developed and served on a single machine (it will be distributed among servers later).

The piece of code below works if I use local host in the URL thus –
http://localhost/TEST/selectTest.aspx

It does not work if I use the machine name –
http://MyMachine/TEST/selectTest.aspx

The alert still pops, but it’s blank if I use the MyMachine name in the URL. It’s fine if I use local host and returns the correct info in the alert.

There are thousands of lines of code in this project that work just fine using the machine name. The only thing that fails is the HTML <select> tag. Any ideas?



<%@ Page Language="VB" AutoEventWireup="false" CodeFile="selectTest.aspx.vb" Inherits="selectTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function testSelect(selected) {
        alert(selected);
    }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
      <select id="Select2" onchange = 'testSelect(this.options[this.selectedIndex].value)'>
              <option selected="selected">
              Select Layer for ID
              </option>
              <option>
               Parcels  
              </option>
              <option>
               Zoning
              </option>
         </select>
    </div>
    </form>
</body>
</html>


No idea what the issue might be between localhost and machine name but…try putting actual values in your option tags.



<option value="Parcels">Parcels</option>


Thanks, that did it. Stange that it has different behavior when I use local host against the machine name…

and duh. Sometimes you just look at something too long, and overlook the obvious.

Those are different Security Zones, assuming you’re testing in IE. (Not sure what other browsers have the concept of Security Zones…)

Loading the page with localhost, your browser assumes it’s talking to a web server. Loading the page with (machine name), your browser assumes it’s talking to a shared fileserver. The security implications are different between the two-- I couldn’t tell you the specifics, but if you look at the Security Zones tab in Internet Options, you can just check for yourself.