打印本文 打印本文 关闭窗口 关闭窗口
ASP.NET POST方式提交数据!
作者:武汉SEO闵涛  文章来源:敏韬网  点击数817  更新时间:2009/4/23 10:44:01  文章录入:mintao  责任编辑:mintao

   string url = "网址";
   HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
   string s = "要提交的数据";
   byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes (LoginInfo);
   req.Method = "POST";
   req.ContentType = "application/x-www-form-urlencoded";
   req.ContentLength = requestBytes.Length;
   Stream requestStream = req.GetRequestStream();
   requestStream.Write(requestBytes,0,requestBytes.Length);
   requestStream.Close();

   HttpWebResponse res = (HttpWebResponse)req.GetResponse();
   StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
   string backstr = sr.ReadToEnd();
   Response.Write(line);
   sr.Close();
   res.Close();

打印本文 打印本文 关闭窗口 关闭窗口