摘要:借助http.sys和.NET 2.0中新增的System.Net.HttpListener类,程序员无需借助IIS就能实现自己的Web服务器,而且代码非常简洁。对此,网上已经发布了不少介绍性的文章,例如:《在没有IIS的条件下运行ASMX》(英语原文:“Run ASMX Without IIS”)、VS2005 Beta1, WSE2.0, http.sys and the HTTPListener: Look Ma, NO IIS以及Using Http.Sys to receive messages with WSE 2.0。
下面是HttpListener的一个最小的完整例子(需要VS.NET 2005 Beta 2):using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Threading;
using System.IO;
namespace MiniHttpsSrv
...{
class Program : IDisposable
...{
static void Main(string[] args)
...{
MiniHttpsSrv.Program server = new Program();
server.Run();
......[
阅读全文]