日期:2014-05-17 浏览次数:20910 次
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace WebRequestTest
{
class Program
{
static void Main(string[] args)
{
WebRequest request = WebRequest.Create("http://gr.xidian.edu.cn/index.do");
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine(response.StatusDescription);
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine(responseFromServer);
reader.Close();
dataStream.Close();
response.Close();
}
}
}
StreamReader reader = new StreamReader(dataStream,Encoding.GetEncoding("GBK"));
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace WebRequestTest
{
class Program
{
static void Main(string[] args)
{
WebRequest request = WebRequest.Create("http://gr.xidian.edu.cn/index.do");
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response&n