- 热门文章:
- · 关于上下文-2 (转自msdn)
- · 关于上下文-1 (转自msdn)
- · ASP.NET移植须知(续)
- · ASP.NET移植须知
- · 深度剖析Duwamish 7.0 (1--数据结构)
- · 用C#实现无需iiS环境就可以执行aspx文件
- · 解决一个比较奇怪的NET问题的方法
- · asp.net datagrid如何在最后一行作求和:
- · HTTPBrowserCapabilities---在asp.net中显示浏览器属性
- · 将xml作为DataGrid 操作(Sort, Edit, Delete)
- · 使用net classes访问其他网站内容
- · 在asp.net中调用Excel 文件
发送HTTP请求的两种方式
public void GetResponse()
{
StringBuilder strSource = new StringBuilder();
try
{
//WebRequest Wreq = WebRequest.Create("http://www.dev-club.com");
//WebResponse Wresp = Wreq.GetResponse();
Uri myUri = new Uri(this.l_strPageAddress);
HttpWebResponse resp;
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create(myUri);
resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream(),Encoding.Default);
string strTemp = "";
while((strTemp = sr.ReadLine()) != null)
{
strSource.Append(strTemp + "\r\n");
}
sr.Close();
}
catch(WebException WebExcp)
{
strSource.Append(WebExcp.Message);
}
this.form.AddMessage(strSource.ToString());
}
public void Socket_GetResponse()
{
IPHostEntry ipinfo = Dns.Resolve(l_strServerAddress);
IPAddress ip = ipinfo.AddressList[0];
IPEndPoint rip = new IPEndPoint(ip,80);
s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
try
{
this.form.AddMessage("Connecting to "+ip.ToString());
s.Connect(rip);
int bytesRecv = 0;
string output = "";
string temp = "";
byte[] bytes;
this.form.AddMessage("Sending request to "+l_strPageAddress);
string Command = "post " +l_strPageAddress+" HTTP/1.0\r\n";
Command += "Accept:*/*\r\n";
Command += "Accept:text/html\r\n";
Command += "\r\n";
byte[] msg = Encoding.Default.GetBytes(Command);
int intSend = s.Send(msg,msg.Length,0);
this.form.AddMessage("Sent "+intSend.ToString()+" bytes to server");
do
{
bytes = new byte[1024];
bytesRecv = s.Receive(bytes,bytes.Length,SocketFlags.None);
temp = Encoding.Default.GetString(bytes,0,bytesRecv);
this.form.AddMessage(temp);
output += temp;
}
while (bytesRecv>0);
this.form.AddMessage(output);
}
catch(Exception e)
{
this.form.AddMessage(e.Message);
}
finally
{
if (s != null & s.Connected)
{
s.Shutdown(SocketShutdown.Both);
s.Close();
}
}
}
下面是结果
Response from remote
Connecting to 61.135.135.13
Sending request to http://dev-club.ccw.com.cn/club/bbs/bbsView.asp?essenceID=18292
Sent 111 bytes to server
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 19 Mar 2002 20:04:23 GMT
pragma: no-cache
cache-control: private
Connection: Keep-Alive
Content-Length: 2025
Content-Type: text/html
Expires: Mon, 18 Mar 2002 20:04:22 GMT
Set-Cookie: ASPSESSIONIDGQQQQVCK=GELPBBIBLDCMOIOEAIBHINMB; path=/
Cache-control: no-cache
<!--
- Dev-club.com开发者俱乐部
- Based on Active BBS 5.0 By shenpengfei@hotmail.com
- Last Updated: 2001-12-1
-->
<html>
<head>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
<link REL="SHORTCUT ICON" href="http://www.chinaasp.com/icon.ico">
<link rel="stylesheet" type="text/css" href="css/style.CSS">
<title>计算机世界开发者俱乐部</title>
<style>
.navPoint
{
font-family: Webdings;
font-size:9pt;
color:black;
cursor:hand;
}
p{
font-size:9pt;
}
</style>
<script language="javascript" src="js/rollover.js">
</script>
<script language="javascript">
var bLoad=false;
function doRefresh(){
self.frames[1].location="refresh.asp
"
setTimeout("doRefresh()",60000)
}
function init(){
doRefresh()
//MM_preloadImages(@#Images/head_about_on.gif@#,@#Images/head_course_on.gif@#,@#Images/head_partner_on.gif@#,@#Images/head_news_on.gif@#,@#Images/head_continue_on.gif@#,@#Images/head_job_on.gif@#);
}
window.onload = doRefresh
</script>
<script language="javascript1.1" src="js/dcookie.js"></script>
<script>
if (do
cument.all==null) window.location.href="NotIEView.asp?essenceID=18292"
function monitor(){
window.open(@#userMonitor.asp@#,@#_blank@#,@#left=3000,top=4000@#)
}
//window.onunload = monitor
</script>
</head>
<frameset name=forum rows="28,*" noresize scrolling="no" border=0 frameborder="0" bordercolor="white" framespacing="0" >
<frame name=title src="title.asp" noresize scrolling="no" >
<frameset name=content cols="150,*" noresize scrolling="no" border=0 frameborder="0" framespacing="0">
<frameset name=menu noresize scrolling="no" border=0 frameborder="0" framespacing="0" rows="20,*">
<frame name="BoardRefresh" noresize scrolling="no" src="">
<frame name="BoardTitle" noresize scrolling="no" target="BoardMenu" src="menu.asp">
</frameset>
<frame src="main.asp?essenceid=18292" name="BoardMain">
</frameset>
</frameset>
<noframes>
<body>
sorry ! your browser not support frame!
</body>
</noframes>
</html>
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 19 Mar 2002 20:04:23 GMT
pragma: no-cache
cache-control: private
Connection: Keep-Alive
Content-Length: 2025
Content-Type: text/html
Expires: Mon, 18 Mar 2002 20:04:22 GMT
Set-Cookie: ASPSESSIONIDGQQQQVCK=GELPBBIBLDCMOIOEAIBHINMB; path=/
Cache-control: no-cache
<!--
- Dev-club.com开发者俱乐部
- Based on Active BBS 5.0 By shenpengfei@hotmail.com
- Last Updated: 2001-12-1
-->
<html>
<head>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
<link REL="SHORTCUT ICON" href="http://www.chinaasp.com/icon.ico">
<link rel="stylesheet" type="text/css" href="css/style.CSS">
<title>计算机世界开发者俱乐部</title>
<style>
.navPoint
{
font-family: Webdings;
font-size:9pt;
color:black;
cursor:hand;
}
p{
font-size:9pt;
}
</style>
<script language="javascript" src="js/rollover.js">
</script>
<script language="javascript">
var bLoad=false;
function doRefresh(){
self.frames[1].location="refresh.asp"
setTimeout("doRefresh()",60000)
}
function init(){
doRefresh()
//MM_preloadImages(@#Images/head_about_on.gif@#,@#Images/head_course_on.gif@#,@#Images/head_partner_on.gif@#,@#Images/head_news_on.gif@#,@#Images/head_continue_on.gif@#,@#Images/head_job_on.gif@#);
}
window.onload = doRefresh
</script>
<script language="javascript1.1" src="js/dcookie.js"></script>
<script>
if (document.all==null) window.location.href="NotIEView.asp?essenceID=18292"
function monitor(){
window.open(@#userMonitor.asp@#,@#_blank@#,@#left=3000,top=4000@#)
}
//window.onunload = monitor
</script>
</head>
<frameset name=forum rows="28,*" noresize scrolling="no" border=0 frameborder="0" bordercolor="white" framespacing="0" >
<frame name=title src="title.asp" noresize scrolling="no" >
<frameset name=content cols="150,*" noresize scrolling="no" border=0 frameborder="0" framespacing="0">
<frameset name=menu noresize scrolling="no" border=0 frameborder="0" framespacing="0" rows="20,*">
<frame name="BoardRefresh" noresize scrolling="no" src="">
<frame name="BoardTitle" noresize scrolling="no" target="BoardMenu" src="menu.asp">
</frameset>
<frame src="main.asp?essenceid=18292" name="BoardMain">
</frameset>
</frameset>
<noframes>
<body>
sorry ! your browser not support frame!
</body>
</noframes>
</html>
两者只相差头信息而已,速度体会不出多大的差别
下一篇:关于上下文-2 (转自msdn) >>
相关文章:
- · 如何利用RowFilter 属性从一个dataset中创建两个不同的datagrid
- · 使用.NET访问Internet(5) Paul_Ni(原作)(补充)
- · 使用.NET访问Internet(5) Paul_Ni(原作)
- · 使用.NET访问Internet(4) Paul_Ni(原作)(补充)
- · 使用.NET访问 Internet(3) Paul_Ni(原作)
- · 使用.NET访问Internet(4) Paul_Ni(原作)
- · 使用.NET访问 Internet(2) Paul_Ni(原作)
- · 修改后的Whois查询程序
- · 使用.NET访问 Internet(1) Paul_Ni(原作)
- · 如何取得动态装载的WEB CONTROL的属性值?
- · POP3 Client as a C# Class(转自CodeProject)
- · 饼图的一种画法(转载自aspcool)
- · 精品:Asp3.0中email有效性验证
- · 使用Div加速页面的显示(原创)
- · Creating DataGrid Templated Columns Dynamically - Part I(转自Dotnettips)
- · 关于asp.net的代码重用
- · Getting Datagrid Columns Keypress,Keyup, Keydown and other events to Fire(一个很好的东西)
- · runat=server
- · 关于上下文(Context)/2(转MS)
- · 关于上下文(Context)/1(转MS)
- · 在.NET中使用静态变量来代替Application变量
- · ASP.NET窗体对话框的实现
- · 用.NET创建定时缓存
- · 将Session值储存于SQL Server中
- · ASP.NET中的事务处理和异常处理
- · ASP.NET Caching /2
- · 嘿,懒鬼!!其实MSDN阐述得真得不错哎,不知道你从哪来的资料
- · ASP.NET Caching /1
- · 绝对酷,如何解决asp.net中javascript脚本的问题(使用服务器控件执行客户端脚本)
- · 最佳ASP.NET编程习惯
- · 一次同时上传多个文件
- · 在datagrid中求和(vb.net,c#)
- · ASP.NET中利用SQLXML WEB服务访问XML数据(转)
- · 在DataGrid中经弹出窗口确认后执行操作(删除)。(附在DataGrid中修改,添加记录)详见代码!!
- · 在datagrid中放入一个DropDownList(忘了这个问题在那里看到的了CSDN or There)
- · 简单的动态加载用户控件的方法
- · 关于如何 确认删除的另外一个办法。
- · 掉掉注意了,如何动态加载用户控件(ascx)
