C# HttpListener Prefix issue with anything other than localhost

Posted by jchristner on Stack Overflow See other posts from Stack Overflow or by jchristner
Published on 2010-04-02T01:53:02Z Indexed on 2010/04/02 2:03 UTC
Read the original article Hit count: 1598

Filed under:
|
|
|

Hello,

I'm trying to use C# and HttpListener with a prefix of anything other than localhost and it fails (i.e. if I give it "server1", i.e.

h t t p : / / l o c a l h o s t : 1 2 3 4 works, but

h t t p : / / s e r v e r 1 : 1 2 3 4 fails

(sorry, but the site thinks I'm trying to spam... the spaces are there because of that...)

The code is...

        HttpListener listener = new HttpListener();
        String prefix = "h t t p : / / s e r v e r 1 : 1 2 3 4/";
        listener.Prefixes.Add(prefix);
        listener.Start();

The failure occurs on listener.Start() with an exception of "Access is denied.".

Any ideas?

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about httpwebrequest