private void ProcessRequest(HttpListenerContext context) { var request = context.Request; var response = context.Response; string responseString; string ssid = null; string password = null; bool isApSet = false; switch (request.HttpMethod) { case "GET": string[] url = request.RawUrl.Split('?'); if (url[0] == "/favicon.ico") { response.ContentType = "image/png"; byte[] responseBytes = Resources.GetBytes(Resources.BinaryResources.favicon); OutPutByteResponse(response, responseBytes); } else { response.ContentType = "text/html"; responseString = ReplaceMessage(Resources.GetString(Resources.StringResources.main), ""); OutPutResponse(response, responseString); } break; case "POST": // Pick up POST parameters from Input Stream Hashtable hashPars = ParseParamsFromStream(request.InputStream); ssid = (string)hashPars["ssid"]; password = (string)hashPars["password"]; Debug.WriteLine($"Wireless parameters SSID:{ssid} PASSWORD:{password}"); string message = "<p>New settings saved.</p><p>Rebooting device to put into normal mode</p>"; responseString = CreateMainPage(message); OutPutResponse(response, responseString); isApSet = true; break; } response.Close(); if (isApSet && (!string.IsNullOrEmpty(ssid)) && (!string.IsNullOrEmpty(password))) { // Enable the Wireless station interface Wireless80211.Configure(ssid, password); // Disable the Soft AP WirelessAP.Disable(); Thread.Sleep(200); Power.RebootDevice(); } }