Skip to content

Instantly share code, notes, and snippets.

@factormystic
Created January 22, 2014 00:55
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 factormystic/8551629 to your computer and use it in GitHub Desktop.
Save factormystic/8551629 to your computer and use it in GitHub Desktop.
Listening on http in c# without a uac prompt
c:\>curl http://localhost:65432/wat/
Hiya mister curl/7.26.0
c:\>
using System.Net;
namespace TestHttpServer
{
class Program
{
static void Main(string[] args)
{
using(var s = new HttpListener()){
s.Prefixes.Add("http://localhost:65432/wat/");
s.Start();
var c = s.GetContext();
c.Response.Close(System.Text.UTF8Encoding.UTF8.GetBytes("Hiya mister " + c.Request.Headers["User-Agent"]), true);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment