views:

517

answers:

1

Hi,

I am writing a test web service, and noticed a strange corner case. If you include two slashes after the port, the method will be called anyway for localhost, localhost:80, 127.0.0.1, and 127.0.0.1:80. But if I try it on the web server I'm developing on (port 55731), it fails.

localhost.Service1 s = new localhost.Service1();
string uri = "http://localhost//testService.asmx";
s.Url = uri;
double result = s.multiply(5,5);

Here's the specific cases:

uri = "http://localhost//testService.asmx"; // works
uri = "http://localhost:80//testService.asmx"; // works
uri = "http://127.0.0.1//testService.asmx"; // works
uri = "http://127.0.0.1:80//testService.asmx"; // works
uri = "http://localhost:55731//testService.asmx"; // fails - HTTP status 400 - bad request

Any idea why this is the case? I know I should have just one slash after the port, just curious.

+2  A: 

It's an implementation detail specific to a web server. One server may consolidate the slashes into a single slash, another may look for a directory with an empty string as the name, or does a pattern check on it.

I'm assuming your webserver on port 80 is differnt from the one on 55731, IIS has many differences from the devserver.

Kekoa