Solved

Http Listener Context

Posted on 2013-06-21
3
361 Views
Last Modified: 2013-06-24
My code below keeps stopping at the context line
Dim ctx As HttpListenerContext = listener.GetContext()

No error...no exception..it just exits.

Any ideas?

        Using listener As New HttpListener()
            listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate
            listener.Prefixes.Add("https://localhost/")
            listener.Start()

            Dim ctx As HttpListenerContext = listener.GetContext()
            ctx.Response.StatusCode = 200
            Dim name As String = ctx.Request.QueryString("name")

            Dim writer As New StreamWriter(ctx.Response.OutputStream)
            writer.WriteLine("<P>Hello, {0}</P>", name)

            writer.WriteLine("<ul>")
            For Each header As String In ctx.Request.Headers.Keys
                writer.WriteLine("<li><b>{0}:</b> {1}</li>", header, ctx.Request.Headers(header))
            Next
            writer.WriteLine("</ul>")

            writer.Close()
            ctx.Response.Close()
            listener.[Stop]()
        End Using

Open in new window

0
Comment
Question by:lrbrister
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39268670
If you enclose it in try catch block then does it go to catch block?
0
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 39269501
0
 

Author Closing Comment

by:lrbrister
ID: 39271359
That did it, and I found the error.

And....

Duh on me!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now