日期:2014-05-17  浏览次数:20873 次

POST方法的参数怎么写?
public static string PostModel(string strUrl, string strParm)  
   {  
    Encoding encode = System.Text.Encoding.Default;  
 
    byte[] arrB = encode.GetBytes(strParm);  
    string strBaseUrl = null;  
    
    HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(strUrl);  
    myReq.Method = "POST" ;  
    myReq.ContentType = "application/x-www-form-urlencoded";   
    myReq.ContentLength = arrB.Length;  
    Stream outStream = myReq.GetRequestStream();             
    outStream.Write(arrB,0,arrB.Length);  

.... 后续代码不贴了,贴了也没用

我想问一下,这个strParm的参数应该怎么写呢?
POST方法不是成对出现的吗?

谁能给我写个调用该方法的例子?
指教了~~

------解决方案--------------------
refer:
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://fanyi.baidu.com/transcontent");
            Encoding encoding = Encoding.UTF8;
            string param = "ie=utf-8&source=txt&query=hello&t=1327829764203&token=8a7dcbacb3ed72cad9f3fb079809a127&from=auto&to=auto";
            //encoding.GetBytes(postData);
            byte[] bs = Encoding.ASCII.GetBytes(param);
            string responseData = String.Empty;
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            req.ContentLength = bs.Length;