Self contained web API run exe from cmd RRS feed

  • Question

  • User228832095 posted
    I've got a self hosted web API which runs in a console, is there anyway I can run this console exe from command prompt and specify a port number to run from as an argument ? & If you can what would the command look like & do I need to change anything in my project to allow for this ?
    Friday, May 15, 2020 8:32 PM

All replies

  • User-474980206 posted

    It’s up to use to decide. The command line arg are passed to the main. Common convent is if want it as an option it’s

       -<single letter>:<value>
       —<multiple letters>:<value>

        myapp -p:8080

        myapp —port:8080

    You of course write a simple parser and pass the value to the port declaration code.

    note: all asp.net core webapi apps are command line apps. See program.cs to access args 

    Saturday, May 16, 2020 8:28 PM