WebServer, MicroFramework, C# y sin Gadgeteer

Por peticion de un amable lector…

Como punto de entrada para construir un ‘WebServer’ sin gadgeteer en C# y para microframework, os dejo la siguiente entrada :

        NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
        WebEvent myweb;
        void ProgramStarted()
            Debug.Print("Program Started");
            Debug.Print("IP Address: "  + networkInterface.IPAddress.ToString());
            Debug.Print("Subnet Mask: " + networkInterface.SubnetMask.ToString());
            Debug.Print("Gateway: "     + networkInterface.GatewayAddress.ToString());
            WebServer.StartLocalServer(networkInterface.IPAddress.ToString(), 80);
            myweb = WebServer.SetupWebEvent("Hello");
            myweb.WebEventReceived +=new WebEvent.ReceivedWebEventHandler(myweb_WebEventReceived);

        void myweb_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
            byte[] bte = new System.Text.UTF8Encoding().GetBytes("Hello from " + networkInterface.IPAddress.ToString() + "At " + System.DateTime.Now.ToString());
            responder.Respond(bte, "text/html");


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.