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

网络编程的一个问题

  Encoding   encoding   =   Encoding.GetEncoding( "GB2312 ");                               
                                string   strUrl   =   @ "http:// "   +   DefaultIP   +   " "   +   DefaultUrl   +   " "; 
                                string   postData   = "username= "+UserName+ "&password= "+password+ "&area_c=&telfile1= "+TelePhones+ " ";                               
                                byte[]   data   =   encoding.GetBytes(postData); 
                                //   准备HTTP请求... 
                                System.Net.HttpWebRequest   myRequest   =   (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strUrl); 
                                myRequest.Method   =   "POST "; 
                                myRequest.ContentType   =   "application/x-www-form-urlencoded "; //运行提示无法按照请求设置空的或空白的方法
                                myRequest.ContentLength   =   data.Length;