title: HttpListener from .NET 4.5 doesn't recognize socket as WebSocket
body: <p>From the .NET 4.5 FW there is builtin support for WebSockets handling.</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/system.net.websockets.websocket(v=vs.110).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.net.websockets.websocket(v=vs.110).aspx</a></p>
  
  <p>The definition for creating WebSocket() instance in JS is simple as a crystal.
  Also... the way to handle WebSocket request in C# using .NET 4.5 is also simple...
  So I don't understand why in server-side code the incoming packet doesn't correspond to:</p>
  
  <p><code>listenerContext.Request.IsWebSocketRequest</code></p>
  
  <p>And it responses the 400 code (in else block).</p>
  
  <p>My client code:</p>
  
  <pre><code>&lt;script&gt;
      function connect() {
          var ws = new WebSocket("ws://localhost:80/wsDemo/");
          ws.onopen = function () {
              alert("About to send data");
              ws.send("Hello World");
              alert("Message sent!");
          };
  
          ws.onmessage = function (evt) {
              alert("About to receive data");
              var received_msg = evt.data;
              alert("Message received = "+received_msg);
          };
          ws.onclose = function () { alert("Connection is closed..."); };
      };
  
      window.load = connect;
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Server-side code:</p>
  
  <pre><code>    public async void Start(string listenerPrefix)
      {
          HttpListener listener = new HttpListener();
          listener.Prefixes.Add(listenerPrefix);
          listener.Start();
          Console.WriteLine("Listening...");
  
          while (true)
          {
              HttpListenerContext listenerContext = await listener.GetContextAsync();
              if (listenerContext.Request.IsWebSocketRequest)
              {
                  ProcessRequest(listenerContext);
              }
              else
              {
                  listenerContext.Response.StatusCode = 400;
                  listenerContext.Response.Close();
              }
          }
      }
  </code></pre>