HTTP SERVER external ip prefix












0














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:UsersriccaDesktopHTTP SERVERHTTP SERVERProgram.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










share|improve this question




















  • 1




    netsh http show urlacl/netsh http add urlacl, or run your process elevated. Unprivileged code isn't allowed to register arbitrary prefixes.
    – Jeroen Mostert
    Nov 23 '18 at 20:42










  • @JeroenMostert Please post this as an answer!
    – MEMark
    Nov 23 '18 at 20:45










  • @MEMark: There has to be a duplicate question for this, I'm just too lazy to search for it and close it appropriately.
    – Jeroen Mostert
    Nov 23 '18 at 20:46










  • @JeroenMostert the server url is already in the urlacl list
    – Riccardo Raffini
    Nov 23 '18 at 20:50










  • did you intent to use HttpS?
    – krish KM
    Nov 23 '18 at 21:01
















0














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:UsersriccaDesktopHTTP SERVERHTTP SERVERProgram.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










share|improve this question




















  • 1




    netsh http show urlacl/netsh http add urlacl, or run your process elevated. Unprivileged code isn't allowed to register arbitrary prefixes.
    – Jeroen Mostert
    Nov 23 '18 at 20:42










  • @JeroenMostert Please post this as an answer!
    – MEMark
    Nov 23 '18 at 20:45










  • @MEMark: There has to be a duplicate question for this, I'm just too lazy to search for it and close it appropriately.
    – Jeroen Mostert
    Nov 23 '18 at 20:46










  • @JeroenMostert the server url is already in the urlacl list
    – Riccardo Raffini
    Nov 23 '18 at 20:50










  • did you intent to use HttpS?
    – krish KM
    Nov 23 '18 at 21:01














0












0








0







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:UsersriccaDesktopHTTP SERVERHTTP SERVERProgram.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










share|improve this question















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:UsersriccaDesktopHTTP SERVERHTTP SERVERProgram.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







c# ip-address router httpserver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 20:41







Riccardo Raffini

















asked Nov 23 '18 at 20:01









Riccardo RaffiniRiccardo Raffini

115




115








  • 1




    netsh http show urlacl/netsh http add urlacl, or run your process elevated. Unprivileged code isn't allowed to register arbitrary prefixes.
    – Jeroen Mostert
    Nov 23 '18 at 20:42










  • @JeroenMostert Please post this as an answer!
    – MEMark
    Nov 23 '18 at 20:45










  • @MEMark: There has to be a duplicate question for this, I'm just too lazy to search for it and close it appropriately.
    – Jeroen Mostert
    Nov 23 '18 at 20:46










  • @JeroenMostert the server url is already in the urlacl list
    – Riccardo Raffini
    Nov 23 '18 at 20:50










  • did you intent to use HttpS?
    – krish KM
    Nov 23 '18 at 21:01














  • 1




    netsh http show urlacl/netsh http add urlacl, or run your process elevated. Unprivileged code isn't allowed to register arbitrary prefixes.
    – Jeroen Mostert
    Nov 23 '18 at 20:42










  • @JeroenMostert Please post this as an answer!
    – MEMark
    Nov 23 '18 at 20:45










  • @MEMark: There has to be a duplicate question for this, I'm just too lazy to search for it and close it appropriately.
    – Jeroen Mostert
    Nov 23 '18 at 20:46










  • @JeroenMostert the server url is already in the urlacl list
    – Riccardo Raffini
    Nov 23 '18 at 20:50










  • did you intent to use HttpS?
    – krish KM
    Nov 23 '18 at 21:01








1




1




netsh http show urlacl/netsh http add urlacl, or run your process elevated. Unprivileged code isn't allowed to register arbitrary prefixes.
– Jeroen Mostert
Nov 23 '18 at 20:42




netsh http show urlacl/netsh http add urlacl, or run your process elevated. Unprivileged code isn't allowed to register arbitrary prefixes.
– Jeroen Mostert
Nov 23 '18 at 20:42












@JeroenMostert Please post this as an answer!
– MEMark
Nov 23 '18 at 20:45




@JeroenMostert Please post this as an answer!
– MEMark
Nov 23 '18 at 20:45












@MEMark: There has to be a duplicate question for this, I'm just too lazy to search for it and close it appropriately.
– Jeroen Mostert
Nov 23 '18 at 20:46




@MEMark: There has to be a duplicate question for this, I'm just too lazy to search for it and close it appropriately.
– Jeroen Mostert
Nov 23 '18 at 20:46












@JeroenMostert the server url is already in the urlacl list
– Riccardo Raffini
Nov 23 '18 at 20:50




@JeroenMostert the server url is already in the urlacl list
– Riccardo Raffini
Nov 23 '18 at 20:50












did you intent to use HttpS?
– krish KM
Nov 23 '18 at 21:01




did you intent to use HttpS?
– krish KM
Nov 23 '18 at 21:01












1 Answer
1






active

oldest

votes


















0














This is not a programming problem.



The networking related classes do not care if the other end is on the same computer (loopback IP), on the same switch or on the Voyager 2 Probe*. If it works vs loopback IP, only network reasons might prevent it to work inside the network or through a router**.



Making certain there is a path is a Networking Problem, not a programming one. You are trying to access it from the Internet side of your router. That is not a trivial thing in the least. Indeed it goes into "how do I host a server in the Internet". Common workarounds include to "just use a VPN and learn to live without this function".



*Not 100% of course. You need pretty long timeouts for several lightmintues worth of distance. Wich might require some progamm setup.



**Small caveat stuff like the SQL servers default installations tend to be protected from being access anyway except loopback IP. A usual consideration for default passwords/useraccounts. Proper instances do not suffer that limitation.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452358%2fhttp-server-external-ip-prefix%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This is not a programming problem.



    The networking related classes do not care if the other end is on the same computer (loopback IP), on the same switch or on the Voyager 2 Probe*. If it works vs loopback IP, only network reasons might prevent it to work inside the network or through a router**.



    Making certain there is a path is a Networking Problem, not a programming one. You are trying to access it from the Internet side of your router. That is not a trivial thing in the least. Indeed it goes into "how do I host a server in the Internet". Common workarounds include to "just use a VPN and learn to live without this function".



    *Not 100% of course. You need pretty long timeouts for several lightmintues worth of distance. Wich might require some progamm setup.



    **Small caveat stuff like the SQL servers default installations tend to be protected from being access anyway except loopback IP. A usual consideration for default passwords/useraccounts. Proper instances do not suffer that limitation.






    share|improve this answer


























      0














      This is not a programming problem.



      The networking related classes do not care if the other end is on the same computer (loopback IP), on the same switch or on the Voyager 2 Probe*. If it works vs loopback IP, only network reasons might prevent it to work inside the network or through a router**.



      Making certain there is a path is a Networking Problem, not a programming one. You are trying to access it from the Internet side of your router. That is not a trivial thing in the least. Indeed it goes into "how do I host a server in the Internet". Common workarounds include to "just use a VPN and learn to live without this function".



      *Not 100% of course. You need pretty long timeouts for several lightmintues worth of distance. Wich might require some progamm setup.



      **Small caveat stuff like the SQL servers default installations tend to be protected from being access anyway except loopback IP. A usual consideration for default passwords/useraccounts. Proper instances do not suffer that limitation.






      share|improve this answer
























        0












        0








        0






        This is not a programming problem.



        The networking related classes do not care if the other end is on the same computer (loopback IP), on the same switch or on the Voyager 2 Probe*. If it works vs loopback IP, only network reasons might prevent it to work inside the network or through a router**.



        Making certain there is a path is a Networking Problem, not a programming one. You are trying to access it from the Internet side of your router. That is not a trivial thing in the least. Indeed it goes into "how do I host a server in the Internet". Common workarounds include to "just use a VPN and learn to live without this function".



        *Not 100% of course. You need pretty long timeouts for several lightmintues worth of distance. Wich might require some progamm setup.



        **Small caveat stuff like the SQL servers default installations tend to be protected from being access anyway except loopback IP. A usual consideration for default passwords/useraccounts. Proper instances do not suffer that limitation.






        share|improve this answer












        This is not a programming problem.



        The networking related classes do not care if the other end is on the same computer (loopback IP), on the same switch or on the Voyager 2 Probe*. If it works vs loopback IP, only network reasons might prevent it to work inside the network or through a router**.



        Making certain there is a path is a Networking Problem, not a programming one. You are trying to access it from the Internet side of your router. That is not a trivial thing in the least. Indeed it goes into "how do I host a server in the Internet". Common workarounds include to "just use a VPN and learn to live without this function".



        *Not 100% of course. You need pretty long timeouts for several lightmintues worth of distance. Wich might require some progamm setup.



        **Small caveat stuff like the SQL servers default installations tend to be protected from being access anyway except loopback IP. A usual consideration for default passwords/useraccounts. Proper instances do not suffer that limitation.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 21:19









        ChristopherChristopher

        2,6501622




        2,6501622






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452358%2fhttp-server-external-ip-prefix%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)