本帖最后由 cn1098035521 于 2011-03-19 15:29:59 编辑

解决方案 »

  1.   

     myRequest.ContentType = "text/html";
    改为
     application/x-www-form-urlencoded
      

  2.   


             换成后,提示下面的消息
    --------------------------------------------------
        <br />
        非常抱歉!</B></BIG></P>
        <div id="ctl00_ctl00_cph_cph_mymsg">
          <P>
              由于您所请求的页面(/User/Login.aspx)存在异常,因此程序无法正确处理您的请求。</P>
        <p>
            造成该异常的发生,可能由于以下情况(但不限于):<br />
            </p></div>
        <span id="ctl00_ctl00_cph_cph_lblErrorMessage"><font color="#FF8080"><li>如果您刚刚是在填写表单,请确认所提交的表单中不含有特别内容,这些内容包括HTML代码等。</li>
            <li>我们的工程师正在对网站进行维护。</li></font></span><br />
      

  3.   

    有可能,我遇到两次了,input name="login$username" 这种带有$符号的都出现这种情况aspx的页面
      

  4.   

    http://wo.zp365.com/public/loginZPGY.aspx这个网站的登录页面代码也是一样,采用同一种方式,也是登录不了
      

  5.   

    你用 HttpUtility.UrlEncode 编码下:/ <summary>
    /// RequestUrl: request some url, return the response.
    /// </summary>
    /// <param name="strUrl">the url</param>
    /// <param name="strPostDatas">the post data</param>
    /// <param name="objCookieContainer">cookie's(session's) container</param>
    /// <returns></returns>
    public static string RequestUrl(string strUrl, string strPostDatas, ref CookieContainer objCookieContainer)  

    HttpWebResponse res = null; 
    string strResponse = ""; try

    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strUrl); 
    req.Method = "POST"; 
    req.KeepAlive = true; 
    req.ContentType = "application/x-www-form-urlencoded";
    //req.Timeout = 20; if(objCookieContainer == null)
    objCookieContainer = new CookieContainer();
    req.CookieContainer = objCookieContainer;

    StringBuilder objEncodedPostDatas = new StringBuilder(); 
    byte[] postDatas = null; req.ContentLength = 0;
    if (strPostDatas != null && strPostDatas.Length > 0)
    {
    string[] datas = strPostDatas.TrimStart('?').Split(new char[] {'&'});
    for(int i=0; i<datas.Length; i++)
    {
    string[] keyValue = datas[i].Split(new char[] {'='});
    if(keyValue.Length >= 2) 
    {
    objEncodedPostDatas.Append(HttpUtility.UrlEncode(keyValue[0]));
    objEncodedPostDatas.Append("=");
    objEncodedPostDatas.Append(HttpUtility.UrlEncode(keyValue[1]));
    if(i < datas.Length - 1) 
    {
    objEncodedPostDatas.Append("&");
    }
    }
    }
    postDatas = Encoding.UTF8.GetBytes(objEncodedPostDatas.ToString()); 
    req.ContentLength = postDatas.Length;
    using(Stream reqStream = req.GetRequestStream())
    {
    reqStream.Write(postDatas, 0, postDatas.Length); 
    }
    } res = (HttpWebResponse)req.GetResponse(); 
    objCookieContainer = req.CookieContainer;
    using(Stream resStream = res.GetResponseStream())
    {
    using(StreamReader sr = new StreamReader(resStream, Encoding.UTF8))
    {
    strResponse = sr.ReadToEnd();
    }
    }
    }
                //catch (Exception ex)
                //{
                //    strResponse = ex.ToString();
                //}  
    finally

    if (res != null)  

    res.Close();

    }
    return strResponse;
    }
      

  6.   

    成功了fangxinggood,太感谢你了!!