WebApi series ~ Implement the self-hosted HttpSelfHost and webapihttpselfhost
The word "host" can be seen as an infrastructure that provides underlying support for some services and functions, for example, your web application can run on iis or apache, and these two items are the web application host. Today, the self-hosted SelfHost is, it can monitor its own services. For example, you can host a web application to a console program, or host a webApi to a console or windowService, this is all possible.
I need to add some assembly references
Code 2 Implementation
# Region Web Api listener var config = new HttpSelfHostConfiguration ("http: // localhost: 3333"); config. routes. mapHttpRoute ("default", "api/{controller}/{id}", new {id = RouteParameter. optional}); var server = new HttpSelfHostServer (config); server. openAsync (). wait (); Console. writeLine ("Server is opened"); # endregion
Test 3