我爱Aspx >> Asp.Net >> C#实现WEB服务器BinaryReader reader = new BinaryReader(fs);
byte[] bytes = new byte[fs.Length];
int read;
while((read = reader.Read(bytes, 0, bytes.Length)) != 0)
{
sResponse = sResponse + Encoding.ASCII.GetString(bytes,0,read);
iTotBytes = iTotBytes + read;
}
reader.Close();
fs.Close();
SendHeader(sHttpVersion, sMimeType, iTotBytes, " 200 OK", ref mySocket);
SendToBrowser(bytes, ref mySocket);
//mySocket.Send(bytes, bytes.Length,0);
}
mySocket.Close();
}
}
}
}
}
///////////结束////////////////
将文件编译成EXE文件,就实现了简单的WEB服务器功能!
可以设定一个虚拟目录,进行测试!
asp.net提供承载asp.net的方法。详细可以看这个例子:
Download ASP.NET Cassini Sample Web Serverhttp://www.asp.net/Projects/Cassini/Download/Default.aspx?tabindex=0&tabid=1
Ҷƪл˵?
C#中时间差的计算[05-20]
C#四种Eval测试结果:不要用Code..[05-20]
通常C#面试题[05-20]
用WebService和javascript实例类..[05-20]
不用.net和其组件用asp访问webse..[05-20]
继承System.Web.UI.Page的页面基..[05-20]
用C#与XML创建动态分层菜单[05-20]
利用WebClient和WebRequest类获得..[05-20]
使用ASP.NET中调用WebService时不..[05-20]
利用SOAP(Webservice)上传文件[05-20]
C#中时间差的计算[05-20]
ASP如何实现文件下载? [ADODB.St..[05-20]
不停滚动特效代码的几个例子[05-20]
加入身份验证信息的SMTP mail发送[05-20]
JS(Unicode->GB)的精简版(仍..[05-20]
利用filter实时切换big5和gb2312..[05-20]
Js中实现拼音和UrlEncode的功能(..[05-20]
汉字转化为拼音(asp版)[05-20]
利用Wipe等ActiveX技术,实现n(n..[05-20]
通过Adodb.Stream取得图像(BMP J..[05-20]