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

关于用Post发送数据的问题,急.........
本帖最后由 wuxi_jj 于 2012-12-15 09:12:22 编辑
 程序一:
 public static string RequestUrl(string a)
    {
        try
        {
            string sessionkey = GetSession();
            string url = "http://192.168.0.11/WebService/Service.asmx/ImportStyle";
            a = a.Replace("\r\n",string.Empty);
            string sendData = "sessionkey="+sessionkey +a ;
            string outputString = String.Empty;
            HttpWebRequest hwrq = (HttpWebRequest)HttpWebRequest.Create(url);
            hwrq.ContentType = "application/x-www-form-urlencoded";
            hwrq.Method = "POST";            byte[] postData = System.Text.Encoding.UTF8.GetBytes(sendData);
            hwrq.ContentLength = postData.Length;
            Stream writeStream = hwrq.GetRequestStream();
            writeStream.Write(postData, 0, postData.Length);
            writeStream.Close();
            HttpWebResponse myResponse = (HttpWebResponse)hwrq.GetResponse();
            StreamReader sr = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
            outputString = sr.ReadToEnd();
            sr.Close();         
        }      
        catch (Exception ex)
        {
            throw ex;
        }
        return null;
    }
程序二:
报错:{"远程服务器返回错误: (500) 内部服务器错误。"}
  public static string RequestUrl(string a)
    {
        try
        {
            string sessionkey = GetSession();
            string url = "http://192.168.0.11/WebService/Service.asmx/ImportStyle?sessionkey="+sessionkey ;        &nb