Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

Http Listener Context

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
lrbrister
Asked:
lrbrister
1 Solution
 
CodeCruiserCommented:
If you enclose it in try catch block then does it go to catch block?
0
 
lrbristerAuthor Commented:
That did it, and I found the error.

And....

Duh on me!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now