title: Simple Web Server: The format of the specified network name is invalid
body: <p>I'm having a problem with a simple web server that I am writing. I need to be able to connect to the server through localhost and IP. However, I am having problems connecting through IP. Here is my code:</p>
  
  <pre><code>private void start_button_Click(object sender, EventArgs e)
      {
          start_button.Text = "Listening...";
  
          HttpListener server = new HttpListener();
  
          server.Prefixes.Add("http://201.0.0.10:69/");
          server.Prefixes.Add("http://localhost:69/");
  
          server.Start();
  
          while (true)
          {
              HttpListenerContext context = server.GetContext();
              HttpListenerResponse response = context.Response;
  
              string page = Directory.GetCurrentDirectory() +
                  context.Request.Url.LocalPath;
  
              if (page == string.Empty)
                  page = page + "index.html";
  
              TextReader tr = new StreamReader(page);
              string msg = tr.ReadToEnd();
  
  
              byte[] buffer = Encoding.UTF8.GetBytes(msg);
  
              response.ContentLength64 = buffer.Length;
              Stream st = response.OutputStream;
              st.Write(buffer, 0, buffer.Length);
  
              context.Response.Close();
          }
      }
  </code></pre>
  
  <p>I keep getting this error: The format of the specified network name is invalid.</p>
  
  <p>I know my problem lies in this bit:</p>
  
  <pre><code>server.Prefixes.Add("http://201.0.0.10:69/");
  </code></pre>
  
  <p>I can connect through localhost if I comment out this line.</p>
  
  <p>Does anyone know what I could be doing wrong?</p>
  
  <hr>
  
  <p>Okay, I got the IP adress working, but now I'm having a problem with this line:</p>
  
  <pre><code>if (page == string.Empty)
              page = page + "index.html";
  </code></pre>
  
  <p>For some reason, it's not adding index.html to the end.</p>