I have an HTTP Server on a Win Console Application
I can access it in my LAN (and that's ok)
But adding the externalIP prefixe gives me an exception when running (not in the ide)
I have set port Forwarding in my router for port 4100
I have disabled my PC firewall
Exception:
System.Net.HttpListenerException (0x80004005): Parametro non corretto
in System.Net.HttpListener.AddAllPrefixes()
in System.Net.HttpListener.Start()
in HTTP_SERVER.Program.Main(String[] args) in C:\Users\ricca\Desktop\HTTP SERVER\HTTP SERVER\Program.cs:riga 34
Just in case:
Parametro non corretto --> incorrect parameter
riga 34 --> line 34 (where I call listener.Start();
)
Code:
try
{
listener = new HttpListener();
listener.Prefixes.Add("http://localhost:4100/main/");
string externalip = new WebClient().DownloadString("http://icanhazip.com");
Console.WriteLine(externalip);
-->listener.Prefixes.Add("https://"+externalip+":4100/main/");
listener.Prefixes.Add("http://"+ip+":4100/main/");
Console.WriteLine("http://" + ip + ":4100/main/");
listener.Start();
//....
}
catch(WebException eccezione_web)
{
Console.WriteLine(eccezione_web.Status);
}
catch(Exception eccezione)
{
Console.WriteLine(eccezione.ToString());
}
externalip is right
Every answer is welcome