I put together a small embedded HTTP server in a Windows application that listens for updates coming from other devices on the network that speak HTTP.
For each HTTP request, the code that processes the request / response is executed twice, I expect it to be run only once. I tried the code using the AsyncGetContext method and used the synchronous version of GetContext - the end result is the same.
code
public void RunService() { var prefix = "http://*:4333/"; HttpListener listener = new HttpListener(); listener.Prefixes.Add(prefix); try { listener.Start(); _logger.Debug(String.Format("Listening on http.sys prefix: {0}", prefix)); } catch (HttpListenerException hlex) { _logger.Error(String.Format("HttpListener failed to start listening. Error Code: {0}", hlex.ErrorCode)); return; } while (listener.IsListening) { var context = listener.GetContext();
Is there something obvious that I was missing, I did not have enough ideas to identify the problem.
source share