IIS 7.5 returning 404 for unknown host names

Solution 1:

This is by design. A URL Reservation is not the same as a URL Registration, which happens dynamically when an application registers with HTTP.SYS to being listening. In the case of a URL Reservation, HTTP.SYS does not know whether the URL in a given Reservation is simply unavailable temporarily or does not exist at all. All it can know in this case is that there is a valid host name match (because of your strong/weak wildcard), but the URL path does not match for any currently registered listeners.

If you want a 400 or 503 response, then either do not use any URL Reservation, or use explicit URL Reservations that do not include wildcards. In short, if you configure HTTP.SYS such that it can match the prefix of the URL to any Reservation (including dynamic ones created via Registration), then it will either deliver the request to listening application (if the rest matches), or return a 404 if it can't find an active registered listener.

Another solution that may be simpler is to use the IIS service itself to manage sending a 503. To do this don't stop the site, but instead stop the Application Pool(s) associated with it. This will cause a fully qualified match to occur in HTTP.SYS (even with wlidcard URL Reservations), but will result in a 503 because there is no AppPool to deliver the request to.

Solution 2:

Is there an active HTTP Module installed on the IIS instance you're not aware of which captures all requests?

Or did you forget that to stop the Default Web site (which comes with a standard IIS installation) active/running, then there is an empty binding.

The Default Web site standard binding is blank which means it accepts all HTTP host headers.

Solution 3:

OK, after an "enjoyable" several hours with MS tech support, we're not in agreement as to whether this is a bug or not, but we are in agreement the problem stems from the presence of the "http://+5000/Temporary_Listen_Address/" which is added by WCF.

As a "workaround" if you add a more specific urlacl for your site in the format of: netsh http add urlacl url=http://hostname:80/ user=networkservice listen=yes delegate=yes

then you will get a 503, not a 404. I maintain this is a "bug", MS is "checking" (not holding my breath).

For those that hit this, the issue # is REG:112060473529066.