views:

97

answers:

1

How do i allow the HttpListener in vb2005.net to allow outside access?

For testing purposes i have set it up to use the same ports as my webserver uses so there are no firewall issues.

the prefixes are set up to take the localhost on port 80 the realm is unset AuthenticationSchemes = Net.AuthenticationSchemes.Anonymous

it works just fine locally on the machine, but cant be reached by web browser on any other machine on my network

A: 

The problem is probably due to the fact that a remote client will send the request with a host header of 'yourmachinename', and not 'localhost' or the IP address.

Unlike IIS, which handles localhost and the local machine name, and the IP all the same (unless you explicitly set host headers), the HttpListener is particularly picky about the request it'll actually respond to.

Set the listener up so that it's listening for requests on 'yourmachinename' and remote clients should then be able to talk to it. Then, for local testing, make sure you change the host from localhost, because that'll probably no longer work.

Andras Zoltan
so http://yourmachinename:port?im building a class to allow simple webserver functionality to my programs, i found that adding the computer IP allowed the lan access to it, and assuming im using the same ports for apache webserver that do work, can i then use the machine name to get to the outside
Jim
Hi Jim,Yes, that sounds about right - and with the HttpListener you can setup multiple Prefixes (example shown here: http://msdn.microsoft.com/en-us/library/system.net.httplistener.httplistener.aspx) which are specified in full URI form (including the web address, port and path) that the listener will respond to. The upshot is that if you want your listener to respond to 127.0.0.1 (localhost), [local-ip] and [machine-name] you'll have to add all three prefixes to the listener in order for it to work.
Andras Zoltan