您的位置:首页 > 理论基础 > 计算机网络

老外编的程序(八):在CSharp里面使用Http Get方法

2008-05-01 03:57 513 查看
/Author: Duncan Mackenzie
using System;
using System.Net;
using System.IO;

namespace MakeAGetRequest_charp
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
string sURL;
sURL = "Get=_blank>Http://www.microsoft.com";

WebRequest wrGetURL;
wrGetURL = WebRequest.Create(sURL);

WebProxy myProxy = new WebProxy("myproxy",80);
myProxy.BypassProxyOnLocal = true;

wrGetURL.Proxy = WebProxy.GetDefaultProxy();

Stream objStream;
objStream = wrGetURL.GetResponse().GetResponseStream();

StreamReader objReader = new StreamReader(objStream);

string sLine = "";
int i = 0;

while (sLine!=null)
{
i++;
sLine = objReader.ReadLine();
if (sLine!=null)
Console.WriteLine("{0}:{1}",i,sLine);
}
Console.ReadLine();
}
}<
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐