3个回答
展开全部
我觉得不用httprequest那么麻烦,,,,用webclient
我这有个函数
byte[] PostBuffer = Encoding.GetEncoding("gb2312").GetBytes(PostData);
//头部
wc.Headers.Add(HttpRequestHeader.Accept, "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*");
wc.Headers.Add(HttpRequestHeader.AcceptLanguage, "zh-cn");
wc.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
wc.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
wc.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)");
wc.Headers.Add(HttpRequestHeader.Pragma, "no-cac0he");
bytes = wc.UploadData("http://tieba.baidu.com/f", "POST", PostBuffer);//提交请求
//bytes就是返回的BYTE格式,,,,
return Encoding.Default.GetString(bytes);//转string,,,
希望能对您有帮助
我这有个函数
byte[] PostBuffer = Encoding.GetEncoding("gb2312").GetBytes(PostData);
//头部
wc.Headers.Add(HttpRequestHeader.Accept, "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*");
wc.Headers.Add(HttpRequestHeader.AcceptLanguage, "zh-cn");
wc.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
wc.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
wc.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)");
wc.Headers.Add(HttpRequestHeader.Pragma, "no-cac0he");
bytes = wc.UploadData("http://tieba.baidu.com/f", "POST", PostBuffer);//提交请求
//bytes就是返回的BYTE格式,,,,
return Encoding.Default.GetString(bytes);//转string,,,
希望能对您有帮助
展开全部
说的很好了啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
using System.Net;
using System.Text;
using System.IO;
关键核心:
string mbPath =Server.MapPath("template.htm");
Encoding code = Encoding.GetEncoding("gb2312");
StreamReader sr = null;
StreamWriter sw = null;
string str = null;
//读取
try
{
sr = new StreamReader(mbPath, code);
str = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
using System.Text;
using System.IO;
关键核心:
string mbPath =Server.MapPath("template.htm");
Encoding code = Encoding.GetEncoding("gb2312");
StreamReader sr = null;
StreamWriter sw = null;
string str = null;
//读取
try
{
sr = new StreamReader(mbPath, code);
str = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询