Search code examples
c#asp.nethttphandlerhttplistener

HttpListener vs HttpHandler dilemma


In a Windows Service I implemented an HttpListener that will handle incoming HTTP Requests to a certain port, parse the 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!


Solution

  • 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.