“HttpListener.getContext” crashes my program :/

For whatever reason, I cannot create an HTTP listener. As soon as I add “HttpListenerContext context = listener.GetContext();” to my class, the entire program goes “Not Responding” when I debug. I can’t tell if I’m really stupid or just kind of stupid. Here is my code. Please help

 class Listener { public static HttpListener listener = null; public static void start() { try { listener = new HttpListener(); listener.Prefixes.Add("http://localhost:1234/"); listener.Start(); Main.m.log("listener started"); HttpListenerContext context = listener.GetContext(); //OFFENDING CODE } catch (WebException e) { Main.m.log(e.Status.ToString()); } } } 

Please tell me what I’m doing wrong. I’ve spent too much time on this.

If you wanna know, this project is part of my senior prank.

submitted by /u/evan_fisha
[link] [comments]

Leave a Reply