Created
March 5, 2013 12:20
-
-
Save follesoe/5089956 to your computer and use it in GitHub Desktop.
Simple webserver in .NET
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
class WebServer | |
{ | |
public void Start() | |
{ | |
var listener = new System.Net.HttpListener(); | |
listener.Prefixes.Add(BaseUrl); | |
listener.Start(); | |
new Thread(HttpThread).Start(listener); | |
} | |
private void HttpThread(object listenerObj) | |
{ | |
HttpListener listener = (HttpListener)listenerObj; | |
while (true) | |
{ | |
var context = listener.GetContext(); | |
using (context.Response) | |
{ | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment