© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
29 replies
kurumi

❔ REST API but it is HttpListener only available

Hello there, I got a challenge to write good scalable C# REST API app by using only .NET 7 (instead of ASP .NET) with HttpListener.
So I have some questions:
1) As I understood, it will only one
HttpListener
HttpListener
instance that catch all requests on different endpoints - not dedicated
HttpListener
HttpListener
to dedicated endpoint?
2) After I catch connection, I should do
httpListenerInstance.GetContextAsync()
httpListenerInstance.GetContextAsync()
and then transfer it to
ThreadPool.QueueUserWorkItem
ThreadPool.QueueUserWorkItem
?
3) How to execute some logic on needed endpoint? I found an answer by notifying all endpoints like hey my dudes, it is new connection to
/endpoint
/endpoint
can all of you handle it and execute if needed by checking itself context
by using Observer pattern. But I see it may slower my system, is it any way to notify only 1 needed endpoint class?
4)
ThreadPool.QueueUserWorkItem
ThreadPool.QueueUserWorkItem
or it is better to create custom class which will store
ConcurrentQueue<HttpListenerContext>
ConcurrentQueue<HttpListenerContext>
with all my connections and then run another Task which will peak and notify endpoint func (see p.2 and p.3)?

Please leave good advices - I can not use sweety ASP .NET.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ ✅ HttpListener only receives context once
C#CC# / help
4y ago
HttpListener
C#CC# / help
3y ago
✅ API REST
C#CC# / help
8mo ago
✅ REST Api
C#CC# / help
3y ago