Created
January 22, 2014 00:55
-
-
Save factormystic/8551629 to your computer and use it in GitHub Desktop.
Listening on http in c# without a uac prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c:\>curl http://localhost:65432/wat/ | |
Hiya mister curl/7.26.0 | |
c:\> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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