11.5. Respond to HTTP Requests from Your Application

Problem

You want your application to be able to respond to HTTP requests programmatically.

Solution

Use the System.Net.HttpListener class, which was first introduced in .NET Framework 2.0.

NOTE

Your application must be running on Windows XP Service Pack 2 (or later) or Windows 2003 (or later) to use the HttpListener class; otherwise, a System.PlatformNotSupportedException will be thrown when you try to instantiate it. Check the Boolean returned by the Shared property HttpListener.IsSupported to see whether support is available.

How It Works

The HttpListener class provides an easy-to-use mechanism through which your programs can accept and respond to HTTP requests. To use the HttpListener ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.