Spider web server (default page)

how change default page , for my spider fez

i try to create webevent for default page, and not work,

question ??? how change default webevent (default page) for my web server in spider .

//start web server port 80
Gadgeteer.Networking.WebServer.StartLocalServer(ethernet.NetworkSettings.IPAddress, 80);

        raiz = WebServer.SetupWebEvent("/");

i review the WebServer Class, and i try this to change default page (accion) for spider web server.

raiz = WebServer.SetupWebEvent(“index.html”);
raiz.WebEventReceived += new WebEvent.ReceivedWebEventHandler(raiz_WebEventReceived);

void raiz_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
Debug.Print("My Hello world! ");
string content = “

My Hello World!!

byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
responder.Respond(bytes, “text/html”);

This work for change my default web page or resource default (“index.html”) and custom my own.


Your question is very simple, yet not clear. I am not sure how we can help you.

void raiz_WebEventReceived(string path, WebServer.HttpMethod method, Responder responder)
     string content = "<html><body><h1>This is now my custom page?</h1></body></html>";
     byte[] bytes = new System.Text.UTF8Encoding().GetBytes(content);
     responder.Respond(bytes, "text/html");


unfortunately to change that default page you will have to get the source code and change it in there… it is hard coded…

go to gadgeteer.codeplex.com and look for webserver41 or webserver42 depending on which version of netmf you are using and add it to your project, then Open WebServerManager.cs and change the static HTML in there to your liking…



You are correct, in order to change the default page all you have to do is add an Event with the word “index.html” even if you don’t have index.html and your event will capture all web urls…

           var webEventtakepicture1 = WebServer.SetupWebEvent("index.html");
            webEventtakepicture1.WebEventReceived += new WebEvent.ReceivedWebEventHandler(webEventtakepicture_WebEventReceived1);

  static void webEventtakepicture_WebEventReceived1(string path, WebServer.HttpMethod method, Responder responder)
            Debug.Print("Asked for the following file=" + path);
            responder.Respond(Encoding.UTF8.GetBytes("Asked for the following file=" + path),"text/html");

That’s amazing!!

 /// <summary>
        /// Gets the WebServerManager instance, which is handled as a singleton. 
        /// </summary>
        /// <returns>The <see cref="T:GTM.NetworkModule.WebServerManager"/> instance</returns>
        public static WebServerManager GetInstance()
            if (serverManager == null)
                serverManager = new WebServerManager();
                serverManager.DefaultEvent = new WebEvent("index.html");
                serverManager.DefaultEvent.ResponseData = Encoding.UTF8.GetBytes("<html><head></head><body><h1>Hey, it works:-)</h1><p>Your own .NET Gadgeteer Web Server is up and running!</p></body></html>");
                serverManager.DefaultEvent.ContentType = "text/html";

How can i change the DefaultEvent !!! There is no way??? I mean… it would be very nice that WebServer Class expose a “GetDefaultWebEvent()” method… or something like that!!!

Something like:

     /// <summary>
        /// Update the Default Web Event for the server so that an http GET request can be processed.
        /// </summary>
        /// <returns>A <see cref="T:GTM.NetworkModule.WebEvent"/> object that is used to update data and respond to incoming requests.
        /// </returns>
        public static WebEvent GetDefaultWebEvent()
            return WebServerManager.GetInstance().DefaultEvent;

And in this way we can change that default WebEvent behaviour… it’s so easy!!!