WebApi series ~ Implement the self-hosted HttpSelfHost and webapihttpselfhost

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.