This is a mirror of official site: http://jasper-net.blogspot.com/

Implementing a simple HTTP server in .NET Microframework

| Wednesday, September 21, 2011
To follow my previous posts, I’ve started to implement a simple HTTP server in my netduino using .NET Microfamework. I have to admit it was quite easy as there is a HTTP Server example in the samples. I was very impressed that with no OS so no Windows, no Linux, no Mac or any DOS or whatever OS, you can do high level code, create a Web Server in about 2 hours. I haven’t seen something comparable using Java, native C or other languages. There may be ways but here, all the framework is designed to be able to handle any kind of networking, there is even multithreading. I’ll use multithreading in a future post to show how to handle periodic calls.

As I would not use all the functions, I’ve started to simplify the code and kept only what I needed.

So I just kept couple of functions:

    public static void StartHttpServer()
    internal static void RunServer(string prefix)
    static private string GetPathFromURL(string URL)
    private static void ProcessClientGetRequest(HttpListenerContext context)
    static void SendFileOverHTTP(HttpListenerResponse response, string strFilePath)
    class PrefixKeeper

I will not used any post method, so I removed it from the code. I removed also the certificate part because I won’t use HTTPS and removed the secure part as I won’t also use it. It needs to clean a bit the code but nothing really too complicated.


Read more: Laurent Ellerbach
QR: implementing-a-simple-http-server-in-net-microframework.aspx

Posted via email from Jasper-net

0 comments: