3

I'm not very clued up on IIS, but I'm trying to do something that I thought would be quite simple.

All I did was add a binding to the site via IIS. I then undid my change by deleting the binding.

In IE, if I browse to http://localhost:80, I am greeted with a pretty picture with a bunch of welcome messages and a big "IIS7", thanks to the graphic designers at Microsoft.

If I browse to http://mycomputername:80, I'm greeted with 404.

If I browse to anywhere other virtual directory on localhost, I get 404.

Any idea how can I fix it?

3
  • I restored to a restore point to resolve this issue. So unfortunately I don't know what the problem was. And sorry to those who got their answers marked down... it wasn't me :) Nov 15, 2011 at 16:33
  • I'm not sure whether I've misunderstood the question, but I read that you're mostly asking why IE and Chrome are behaving differently? The first thing I'd do is check that one or the other isn't showing you some old state from cache: clear cache from both browsers and then try?
    – eggyal
    Nov 15, 2011 at 16:59
  • I realized after posting the initial question that "I could not access any of the virtual sub-directories on localhost via my browser." By this I refer to any browser. So my question now is why could I suddenly not access anything except for (in IE, and nowhere else) localhost:80 Nov 15, 2011 at 17:13

4 Answers 4

8

HTTP/1.1 compliant web browsers send an HTTP header called "Host" along with every request, to inform the server which name they're requesting resources from - this allows for a server to host multiple separate sites via the same IP address.

Because of this, modern web servers have a baked-in capability to treat requests to different hosts as if they're coming in to a completely different site based on the content of that "Host" header.

In your case, the computer's name is resolving successfully to your local system (exactly what address it resolves to depends on your networking configuration) as is evident from the 404 responses that IIS is generating, but IIS isn't mapping the request to the site that you're expecting it to.

The issue is in your IIS bindings configuration. Your issue is one of three possibilities:

  • The binding on the desired site is not set to the right host name. It may be set to just localhost, while the request is coming in with a header of mycomputername.
  • The binding is not set to the right IP address. It may be set to just 127.0.0.1, while the name resolution process is probably resolving the name to a bound address instead.
  • Even if the desired site's binding matches, another site is getting the request because it has a more applicable binding. For instance, if your desired site is bound to all addresses on a given port, and another site has that same port bound with a more specific address, it will get the request instead.
2

You can do this via hosts file or adding a host header in IIS Manager.

You have IIS looking at a specific IP address only. Go to IIS Manager, then go to properties on the website. Then, from the Web site tab, go to properties.

Add a identity for that host header value.

1

you can edit your c:\windows\system32\drivers\etc\hosts file.. add

127.0.0.1 mycomputername

and try.

3
  • I would have ticked it, but unfortunately adding the entry to my hosts file isn't solving my problem. I think I've annoyed IIS by clicking around without knowing what I'm doing. I've tried iisreset... and now I'll try restart my computer. I was messing around in Bindings earlier, but I thought I put everything back as it was.
    – Lost Hobbit
    Nov 15, 2011 at 13:49
  • did you restart IE after you added the entry?
    – Ya Zhuang
    Nov 15, 2011 at 15:16
  • Yes bitsMix, I did try re-opening IE. Got our web expert to take a look and he couldn't solve it, so I restored to yesterday's restore point and that solved it... still don't know what the problem was though. Nov 15, 2011 at 16:32
-1

you should add your computer name in the hosts file under

C:\Windows\System32\drivers\etc

After that IIS will resolve it properly

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       computername
1
  • the file is hosts (no extension) , not Host Nov 15, 2011 at 13:53

Not the answer you're looking for? Browse other questions tagged .