[Mono-list] cannot bind HttpListener to IP address (+ different behavior in mono / .net)

Kriss Free kriss.free at free.fr
Mon Sep 30 20:19:11 UTC 2013

Hi all,


When I bind a HttpListener to a specific IP address, any url with an
hostname corresponding to that IP that I open in a browser returns a "Bad
Request (Invalid host)" in mono whereas it runs fins in .Net.


The long story:

I have a server with two IP addresses. A web server (apache) is bound to the
first IP. I want to make httplistener listen on the second IP to
host two websites example1.com and example2.com. I cannot use
httplistener.Prefixes.Add("http://*:80/") because apache is already
listening on the first IP (this is normal and expected). So I used
httplistener.Prefixes.Add(""). The command runs fine

- with mono, if I open in a browser "" it works, but
"http://www.example1.com" leads to a "Bad Request (Invalid host)". 

- with .Net, both url works correctly.


Did I miss something?


The tested platforms:

- Mono 3.2.3 on opensuse 12.3

- .NET 4 on Windows 2008R2



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20130930/07fd82ec/attachment.html>

More information about the Mono-list mailing list