This article is a mirror article of machine translation, please click here to jump to the original article.

View: 37550|Reply: 4

[Console Program] HttpSelfHostServer based console web API service

[Copy link]
Posted on 10/30/2020 11:35:33 AM | | | |
I wrote something about the console program using HttpListener to enable HTTP services, as follows:

HttpListener-based web server
https://www.itsvse.com/thread-2545-1-1.html

c# http listens to threads with HttpListener
https://www.itsvse.com/thread-2951-1-1.html

httplistener listens to get the POST request parameters
https://www.itsvse.com/thread-9029-1-1.html

Microsoft has provided the HttpSelfHostServer class, which directly listens to the implementation of HTTP HttpServer. Self-hosted mode HttpSelfHostServer can be hosted by a console program or a Windows service program, and does not depend solely on the IIS web server. It is very powerful and easy to configure. The HttpSelfHostServer type inherits from HttpServer, which is a message handler base class that inherits from the DelegatingHandler abstraction type.

Let's take a look at the renderings as follows:



First, create a new one.NET framework 4.7.2console project

To quote the nuget package, it looks like this:



The program code is as follows:

(End)






Previous:A service based on .NET Core on Linux
Next:docker-ce-3:19.03.13-3.el7.x86_64 requires containerd.io >= 1.2.2-3
Posted on 7/15/2021 8:37:51 PM |
I want it, I want it, I want it, I want it
Posted on 8/18/2022 4:17:49 PM |
Learn it
 Landlord| Posted on 1/9/2024 7:31:54 PM |
Microsoft.AspNet.WebApi.SelfHost is outdated, and Microsoft.AspNet.WebApi.OwinSelfHost is recommended

Documentation:https://learn.microsoft.com/zh-c ... o-self-host-web-api
 Landlord| Posted on 1/9/2024 8:53:40 PM |
.NET/C# console enables the listening https protocol service
https://www.itsvse.com/thread-10718-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com