Skip to content

Instantly share code, notes, and snippets.

@Dykam
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dykam/5b0b8e33fa0cd7294e0d to your computer and use it in GitHub Desktop.
Save Dykam/5b0b8e33fa0cd7294e0d to your computer and use it in GitHub Desktop.
Small stand-alone URL-echoing server
using Microsoft.Owin;
using Microsoft.Owin.Hosting;
using Owin;
using System;
using System.Net.Http;
namespace SelfHost
{
public class Program
{
public void Main(string[] args)
{
var baseAddress = "http://localhost:9000/";
using (WebApp.Start<Startup>(url: baseAddress))
{
Console.WriteLine("Press a key to stop the server...");
Console.ReadKey(true);
}
}
}
public class Startup
{
public void Configuration(IAppBuilder appBuilder)
{
appBuilder.Run(context =>
{
return context.Response.WriteAsync(context.Request.Path.Value);
});
}
}
}
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.WebApi.OwinSelfHost": "5.2.3",
"Microsoft.AspNet.Mvc": "5.2.3"
},
"commands": {
"run": "run"
},
"frameworks": {
"aspnet50": {
"dependencies": {
"System.Console": "4.0.0-beta-22523"
}
}
},
"compilationOptions": {
"languageVersion": "csharp6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment