This project is read-only.

Windows Phone Http Server

This project is contains the required source code to run a http server on your windows phone 8 app.

Example how to use the http server to send an sms:

// create the http server            
HttpServer httpServer = new HttpServer("");

// register an request handler which will handle the posted form data
httpServer.RegisterRequestHandler(new Regex("/sendSms"), request =>
    // get the data send as form data
    FormDataContentProvider formDataProvider = request.Content as FormDataContentProvider;

    // read the data from the form
    string number = formDataProvider.FormData["number"];
    string message = formDataProvider.FormData["message"];

    // use the windows phone SMS api to send a SMS
    SmsComposeTask smsTask = new SmsComposeTask();
    smsTask.To = number;
    smsTask.Body = message;
    // tell the client, that everything went fine
    return new HttpResponse(HttpStatusCode.Ok);

The server also has support for static content such as images, which are handled by a resource manager:

// create the http server            
HttpServer httpServer = new HttpServer("");

// create a resource manager and set the base path
httpServer.ResourceManager = new ResourceManager("webserver");

// add an resource to the resource manager
    "/images/animals/dog.png", // the internal path, relative to the base path to determine the data
    "/images/dog"); // the external path the resource will be reachable at 
                    // (eg will serve
                    // the /webserver/images/animals/dog.png)

Last edited Feb 13, 2013 at 10:01 PM by GameScripting, version 2