public static CookieContainer loginCookie = new CookieContainer();内容太长了,没人看么?

解决方案 »

  1.   

    是不是有登录操作,你看firefox,应该有cookie你没传cookie
      
    *****************************************************************************
    签名档: http://feiyun0112.cnblogs.com/
      

  2.   


    有登陆操作 private string GetLoginData(string url)
            { 
                string respHtml=null;            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                request.ContentType = "application/x-www-form-urlencoded";
                request.UserAgent ="Mozilla/5.0 (Windows; U; Windows NT 5.2; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)";   
                request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
                //request.Referer = server;
                request.Timeout = 4000;
                request.KeepAlive = true;
                request.CookieContainer = loginCookie;            try
                {
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    foreach (Cookie cookie in response.Cookies)
                    {
                        loginCookie.Add(cookie);              
                    }
                    
                    StreamReader myReader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
                    respHtml = myReader.ReadToEnd().Replace("\r\n","");                response.Close();
                    response = null;
                    myReader = null;                return respHtml;
                }
                catch (WebException ex)
                {
                    return respHtml = ex.ToString();
                }
            }
    这个是登陆  把cookie存到一个容器里的   post请求的时候带上了这个容器
    我在做其他get请求的时候 都能返回正确的html代码
      

  3.   

    从提示来看,第二个已经正确提交了.但是由于提交的内容中存在问题或者缺少字段,造成 "类型“System.DBNull”的对象无法转换为类型“System.Int32”。"
      

  4.   


    对啊,我现在也困惑在这里 ,我GET其他页面都没问题,而且html解析我需要的内容我也做好了.
    这个post我都弄了好几天了 还是没弄好  
    有没有大神能远程帮助我我的QQ 35914052   在此谢过
      

  5.   

    InsertCourseStatus:function(CouserID,GradeId,objName,ObjType,ObjID,ObName,callback,context){return new ajax_request(this.url + '?_method=InsertCourseStatus&_session=rw','CouserID=' + enc(CouserID)+ '\r\nGradeId=' + enc(GradeId)+ '\r\nobjName=' + enc(objName)+ '\r\nObjType=' + enc(ObjType)+ '\r\nObjID=' + enc(ObjID)+ '\r\nObName=' + enc(ObName),callback, context);},看看原始信息,他发的参数好像不是用&,是用\r\n连接
      

  6.   

    我试试
    谢谢 大神  已正确返回 OK
    您好,可以教學一下嗎?我也遇到這個問題了,我是用apache http的套件