I am working with the HttpSelfHostServer with asp net mvc 4 web api
When I create the server, I specify a base address, usually somthing like http://foo.com:8080
Lets just say that this server has multiple ips 10.0.0.0, 10.0.0.1, 10.0.0.2
we will also say that
http://foo.compoints to10.0.0.0http://bar.compoints to10.0.0.1http://baz.compoints to10.0.0.2
if the HttpSelfHostServer is bound to http://foo.com:8080 why can I still access it at http://bar.com:8080 and http://baz.com:8080
here is the code that instantiates the server
public Server(string name, Uri baseAddress)
{
Name = name;
TimeCreated = DateTime.Now;
BaseAddress = baseAddress;
var config = new HttpSelfHostConfiguration(BaseAddress);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new {id = RouteParameter.Optional}
);
// Create server
_server = new HttpSelfHostServer(config);
}
you can modify this behavior by changing the HostNameComparisionMode property on HttpSelfHostConfiguration. By default, the value is StrongWildCard.
config.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;
You can read more about this setting here:
http://msdn.microsoft.com/en-us/library/system.servicemodel.hostnamecomparisonmode.aspx