httpwebrequest上传
❶ 怎么用HttpWebRequest进行POST请求,并且把一个很长字符串传过去,然后在被请求页面怎么接受这个字符串
里面有个关键字,Web。就算你是用winform程序请求的,也是属于Web形式请求的,服务器也要用Web程序响应。服务器上用Request.QueryString("参数名")来接受你的这个字符串。一般来说应该请求的服务器跟你没有直接关系吧,不然你也不会这么做了。给你一段代码希望对你有帮助。HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream receiveStream = response.GetResponseStream();
            StreamReader readStream = new StreamReader(receiveStream, Encoding.GetEncoding("GBK"));
            html = readStream.ReadToEnd();
说明:request 类型:HttpWebRequest
❷ httpWebRequest怎么POST,JSON数据
/// <summary>  
       /// 返回JSon数据  
       /// </summary>  
       /// <param name="JSONData">要处理的JSON数据</param>  
       /// <param name="Url">要提交的URL</param>  
       /// <returns>返回的JSON处理字符串</returns>  
        public string GetResponseData(string JSONData,string Url)  
        {byte[] bytes = Encoding.UTF8.GetBytes(JSONData)  
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);  
            request.Method = "POST";  
        request.ContentLength = bytes.Length;  
            request.ContentType = "text/xml";  
            Stream reqstream = request.GetRequestStream();  
            reqstream.Write(bytes, 0, bytes.Length);  
  
            //声明一个HttpWebRequest请求  
            request.Timeout = 90000;  
            //设置连接超时时间  
            request.Headers.Set("Pragma", "no-cache");  
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();  
            Stream streamReceive = response.GetResponseStream();  
            Encoding encoding = Encoding.UTF8;  
  
            StreamReader streamReader = new StreamReader(streamReceive, encoding);  
            string  strResult = streamReader.ReadToEnd();  
            streamReceive.Dispose();  
            streamReader.Dispose();  
  
            return strResult;  
        }  
如果不通过request.write()的方式向接口post数据,将request.ContentLength属性设置为0,让后去掉request.write()方法即可!
❸ 怎么通过HttpWebRequest 把数据发送到服务器上
下:
解决方案1:
我本地有一个zip 数据包,想通过 http post方式 到服务器端,怎么实现?给出具体代码。 以及从服务器端get 文件的方法,高手指点,分不多了,全部奉上
解决方案2:
,只要在浏览器的地址栏里输入网站的地址就可以了,例如,但是在浏览器的地址栏里面出现的却是: ,你知道为什么会多出一个“http”
❹ 谁知道C#使用HttpWebRequest的POST方法发送大量数据的方法
不想一点一点写了,粘贴给你吧
使用 HttpWebRequest 向网站提交数据
HttpWebRequest 是 .net 基类库中的一个类,在命名空间 System.Net 下面,用来使用户通过 HTTP 协议和服务器交互。 
HttpWebRequest 对 HTTP 协议进行了完整的封装,对 HTTP 协议中的 Header, Content, Cookie 都做了属性和方法的支持,很容易就能编写出一个模拟浏览器自动登录的程序。 
程序使用 HTTP 协议和服务器交互主要是进行数据的提交,通常数据的提交是通过 GET 和 POST 两种方式来完成,下面对这两种方式进行一下说明: 
1. GET 方式。 GET 方式通过在网络地址附加参数来完成数据的提交,比如在地址  中,前面部分  表示数据提交的网址,后面部分 hl=zh-CN 表示附加的参数,其中 hl 表示一个键(key), zh-CN 表示这个键对应的值(value)。程序代码如下: 
HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create( "" );
req.Method = "GET";
using (WebResponse wr = req.GetResponse())
{
   //在这里对接收到的页面内容进行处理
} 
2. POST 方式。 POST 方式通过在页面内容中填写参数的方法来完成数据的提交,参数的格式和 GET 方式一样,是类似于 hl=zh-CN&newwindow=1 这样的结构。程序代码如下: 
string param = "hl=zh-CN&newwindow=1";
byte[] bs = Encoding.ASCII.GetBytes(param);
HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create( "" );
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = bs.Length;
using (Stream reqStream = req.GetRequestStream())
{
   reqStream.Write(bs, 0, bs.Length);
}
using (WebResponse wr = req.GetResponse())
{
   //在这里对接收到的页面内容进行处理
} 
在上面的代码中,我们访问了  的网址,分别以 GET 和 POST 方式提交了数据,并接收了返回的页面内容。然而,如果提交的参数中含有中文,那么这样的处理是不够的,需要对其进行编码,让对方网站能够识别。 
3. 使用 GET 方式提交中文数据。 GET 方式通过在网络地址中附加参数来完成数据提交,对于中文的编码,常用的有 gb2312 和 utf8 两种,用 gb2312 方式编码访问的程序代码如下: 
Encoding myEncoding = Encoding.GetEncoding("gb2312");
string address = "" + HttpUtility.UrlEncode("参数一", myEncoding) + "=" + HttpUtility.UrlEncode("值一", myEncoding);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(address);
req.Method = "GET";
using (WebResponse wr = req.GetResponse())
{
   //在这里对接收到的页面内容进行处理
} 
在上面的程序代码中,我们以 GET 方式访问了网址  ,传递了参数“参数一=值一”,由于无法告知对方提交数据的编码类型,所以编码方式要以对方的网站为标准。常见的网站中,  (网络)的编码方式是 gb2312,  (谷歌)的编码方式是 utf8。 
4. 使用 POST 方式提交中文数据。 POST 方式通过在页面内容中填写参数的方法来完成数据的提交,由于提交的参数中可以说明使用的编码方式,所以理论上能获得更大的兼容性。用 gb2312 方式编码访问的程序代码如下: 
Encoding myEncoding = Encoding.GetEncoding("gb2312");
string param = HttpUtility.UrlEncode("参数一", myEncoding) + "=" + HttpUtility.UrlEncode("值一", myEncoding) + "&" + HttpUtility.UrlEncode("参数二", myEncoding) + "=" + HttpUtility.UrlEncode("值二", myEncoding);
byte[] postBytes = Encoding.ASCII.GetBytes(param);
HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create( "" );
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded;charset=gb2312";
req.ContentLength = postBytes.Length;
using (Stream reqStream = req.GetRequestStream())
{
   reqStream.Write(bs, 0, bs.Length);
}
using (WebResponse wr = req.GetResponse())
{
   //在这里对接收到的页面内容进行处理
} 
从上面的代码可以看出, POST 中文数据的时候,先使用 UrlEncode 方法将中文字符转换为编码后的 ASCII 码,然后提交到服务器,提交的时候可以说明编码的方式,用来使对方服务器能够正确的解析。 
以上列出了客户端程序使用 HTTP 协议与服务器交互的情况,常用的是 GET 和 POST 方式。现在流行的 WebService 也是通过 HTTP 协议来交互的,使用的是 POST 方法。与以上稍有所不同的是, WebService 提交的数据内容和接收到的数据内容都是使用了 XML 方式编码。所以, HttpWebRequest 也可以使用在调用 WebService 的情况下。
❺ C++ 怎么把图片转换成字节流,再通过HttpWebRequest上传到指定路径
找个Base64编码 的C++库吧。可以把图片转换为字符串,不过,比较长。
❻ C# HttpWebRequest上传大文件(200M)提示远程主机强迫关闭了一个现有的连接
服务器是自己的? 很多服务器本身有限制上传时间,可以不限制大小,但会限制上传时间。
❼ HttpWebRequest和HttpWebResponse消息的上传和反馈信息的处理
你的代码,第一段图片代码,与第二段手写代码,是不是一个意思?
你的代码,可以满足你的要求。
❽ wince如何实现上传图片到web服务器,我使用的是HttpWebRequest急求
private static void UploadFile(Stream postedStream, string fileName,
 2            string uploadURL, string fileGroup, string fileType,
 3            string specialPath, string userName, string uploadType)
 4        {
 5            if (string.IsNullOrEmpty(uploadURL))
 6                throw new Exception("Upload Web URL Is Empty.");
 7
 8            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uploadURL);
 9
10            //Our method is post, otherwise the buffer (postvars) would be useless
11            webRequest.Method = WebRequestMethods.Http.Post;
12
13            // Proxy setting
14            WebProxy proxy = new WebProxy();
15            proxy.UseDefaultCredentials = true;
16            webRequest.Proxy = proxy;
17
18            //We use form contentType, for the postvars.
19            webRequest.ContentType = "application/x-www-form-urlencoded";
20    
21            webRequest.Headers.Add("FileGroup", fileGroup);
22            webRequest.Headers.Add("FileType", fileType);
23            webRequest.Headers.Add("UploadType", uploadType);
24            webRequest.Headers.Add("FileName", fileName);
25            webRequest.Headers.Add("UserName", userName);
26            webRequest.Headers.Add("SpecialFolderPath", specialPath);
27
28            using (Stream requestStream = webRequest.GetRequestStream())
29            {
30                FileUtility.CopyStream(postedStream, requestStream);
31            }
32            try
33            {
34                webRequest.GetResponse().Close();
35            }
36            catch (WebException ex)
37            {
38                HttpWebResponse response = ex.Response as HttpWebResponse;
39                if (response != null)
40                {
41                    throw new WebException(response.StatusDescription, ex);
42                }
43
44                throw ex;
45            }
46            catch (Exception exception)
47            {
48                throw exception;
49            }
50        }
❾ C#,HttpWebRequest模拟发送Post请求
HttpWebRequest模拟发送Post请求,直接上代码,看例子
1、建立请求函数
///<summary>
///POST请求与获取结果
///</summary>
publicstaticstringHttpPost(stringUrl,stringpostDataStr)
{
HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(Url);
request.Method="POST";
request.ContentType="application/x-www-form-urlencoded";
request.ContentLength=postDataStr.Length;
StreamWriterwriter=newStreamWriter(request.GetRequestStream(),Encoding.ASCII);
writer.Write(postDataStr);
writer.Flush();
HttpWebResponseresponse=(HttpWebResponse)request.GetResponse();
stringencoding=response.ContentEncoding;
if(encoding==null||encoding.Length<1){
encoding="UTF-8";//默认编码
}
StreamReaderreader=newStreamReader(response.GetResponseStream(),Encoding.GetEncoding(encoding));
stringretString=reader.ReadToEnd();
returnretString;
2、调用例子
staticvoidMain(string[]args)
{
stringurl="http://www.mystudy.cn/LoginHandler.aspx";
stringdata="UserName=admin&Password=123";
stringresult=HttpPost(url,data);
Console.WriteLine(result);
Console.ReadLine();
}
3、换成你的参数即可
❿ C#用HttpWebRequest上传数据的问题。
Request可以当成全局变量同url一起传进来 
在方法里只修改Reqest的访问地址就可以了
也就是不用没次都要给Request分配内存 你不是要循环的吗
其它的都没什么问题
