title: C# httplistener error if remote ip
body: <p>I created a httplistener and it works only with localhost as a prefix. It show an error if I change it to a remote server ip. </p>
  
  <p>Here's the code:</p>
  
  <pre><code> HttpListener listener = new HttpListener();
          listener.Prefixes.Add("http://*:8080/");  // I need localhost replaced with remote ip
          listener.Start();
          while (true)
          {
              // Wait for a client request:
              HttpListenerContext context = listener.GetContext();
  
              // Respond to the request:
              string msg = "You asked for: " + context.Request.RawUrl;
              context.Response.ContentLength64 = Encoding.UTF8.GetByteCount(msg);
              context.Response.StatusCode = (int)HttpStatusCode.OK;
  
              using (Stream s = context.Response.OutputStream)
              using (StreamWriter writer = new StreamWriter(s))
                  writer.Write(msg);
          }
          listener.Stop();
  </code></pre>
  
  <p>THis is the web client:</p>
  
  <pre><code>   using (WebClient wc = new WebClient())        // Make a client request.
                      wc.DownloadString
                        ("http://"my public ip"(on  my router):8080/lg.txt"); //port forwarding is set
                  MessageBox.Show("received");
  </code></pre>
  
  <p>It works only if I change "my public ip" to my local ip
  Any ideas?</p>