Skip to content

Instantly share code, notes, and snippets.

@glennblock
Created February 28, 2013 08:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennblock/5055156 to your computer and use it in GitHub Desktop.
Save glennblock/5055156 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Web.Http;
using System.Web.Http.SelfHost;
var address = "http://localhost:8080";
var conf = new HttpSelfHostConfiguration(new Uri(address));
conf.Routes.MapHttpRoute(name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
var server = new HttpSelfHostServer(conf);
server.OpenAsync().Wait();
Console.WriteLine("Listening...");
Console.ReadKey();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment