Gadgeteer WebServer Response error on the client side

Hi to everyone! I run the Gadgeteer WebServer on Fez Raptor. I am using a responder.Respond() method to send a response to windows PC client side. I use Ad-Hoc connection between PC and Raptor via WIFI RS 21 module.

Here is a code:


ProgramStarted()
{
WebEvent status = WebServer.SetupWebEvent("status");
status.WebEventRecived+= status_WebEventRecieved;
WebServer.StartLocalServer(ipaddress,80);
}

void status_WebEventRecieved(string path, WevServer.HttpMathod method, Responder responder)
{
    byte[] data = System.Text.Encoding.UTF8.GetBytes("status");
    responder.Respond(data,"text/html");
}

WebEvent fires with no problem on Raptor side, but client side response event handler that expects System.Net.Http.HttpResponseMessage with text/html content type never fires.

Here is Ad-Hoc connection code i use:


WiFiRS9110.NetworkParameters ACCESSPOINT_PARAMS = new WiFiRS9110.NetworkParameters();
            
            ACCESSPOINT_PARAMS.Channel=6;
            ACCESSPOINT_PARAMS.Key = "";
            ACCESSPOINT_PARAMS.Ssid = "RaptorBOT";
            ACCESSPOINT_PARAMS.NetworkType = WiFiRS9110.NetworkType.AdHoc;
            ACCESSPOINT_PARAMS.SecurityMode = WiFiRS9110.SecurityMode.Open;
            
            wifiRS21.NetworkInterface.Open();
            wifiRS21.UseThisNetworkInterface();
            wifiRS21.NetworkInterface.EnableStaticIP("192.168.0.65", "255.255.0.0", "192.168.0.65");
            wifiRS21.NetworkInterface.StartAdHocNetwork(ACCESSPOINT_PARAMS);

What is the problem? Should i convert the Gadgeteer response on the client side somehow? Or Ad-hoc connection doesn’t allow to send Respond?

the format of your response text is not html.

1 Like

@ Mike -
You are right… Thank you!!! I forgot to change response format on the client side. Before i used text/html. Responder uses text/plain for string type.