Solved

Http Listener Context

Posted on 2013-06-21
3
377 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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