HttpListener vs HttpHandler dilemma
In a Windows Service I implemented an HttpListener that will handle incoming HTTP Requests to a certain port, parse th开发者_高级运维e query string, insert it in database and send a confirmation response. All works well and i was quite pleased with my solution. However, the clients said that they were a bit skeptical and asked if the same could have been done via a webpage. Like having an HTTPHandler listen to a certain port. Got me thinking. What would you do in my situation?
Go with the HttpListener/Windows Service or HTTPHandler/.aspx?
Thank you very much!
Is there any reason why you don't want to use a web server? We've implemented our own Http serving services because they are fairly unusual in the way they process the requests and would prove taxing on a normally configured IIS instance.
In your situation, this doesn't appear to be the case, so yes, I find myself wondering why you didn't go the webserver route either.
EDIT
Is there any other web facing part of your application? If not, I would concur that @Mr Disappoinment's reasoning is sound. You're only exposing what you need, which is considerably less attack surface than an IIS instance.
I would use something through IIS, simply because I think my clients' IT staffs would require a pretty significant argument for me to be telling them to install custom services on their servers. I don't know enough about the threading behavior of the HttpListener (does it use thread pools? max number of threads? queueing once a max has been hit?) to say for sure, but I'd imagine that your client has similar concerns.
精彩评论