表单提交可以了,登陆后竟然显示的全部是框架......,显示的代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>cwchyt-用户管理后台</title>
</head><frameset rows="*" cols="156,8,*" framespacing="0" frameborder="0" border="false" id="frame" scrolling="yes"><frame name="left" scrolling="auto" marginwidth="0" marginheight="0" src="user_top.asp?actiontype=left"><frame src="user_top.asp?actiontype=center" scrolling="no"><frame name="main" scrolling="auto" marginwidth="0" marginheight="0" src="user_index.asp?actiontype=main"></frameset><noframes></noframes></html>有没有办法把框架里面的内容也显示出来?
如果需要HttpWebResponse跳转,应该怎样设置?

解决方案 »

  1.   

    对了,网页地址为:http://www.hzxsjy.com/blog/login.asp程序代码:
          string html = "";
            private string req(string postdata)
            {
                //*****************设置发送时的初始化*****************
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.hzxsjy.com/blog/login.asp");
                CookieContainer cook = new CookieContainer();
                byte[] bData = null;
                bData = Encoding.GetEncoding("gb2312").GetBytes(postdata);
                request.ContentLength = bData.Length;//要发送数据的字节长度
                request.Method = "Post"; //协议方法
                request.ContentType = "application/x-www-form-urlencoded"; //请求类型
                request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
                request.KeepAlive = true;//持久性连接
                request.CookieContainer = cook;
                request.AllowAutoRedirect = true;            //*************向网站通过POST发送数据***********************            Stream newStream = request.GetRequestStream();//创建流
                newStream.Write(bData, 0, bData.Length);      //将要发送的字节数组写入流
                newStream.Close();//关闭
                request.AllowAutoRedirect = true;
                //****************接收返回的数据********************
                HttpWebResponse rep = (HttpWebResponse)request.GetResponse(); //返回对请求的相应
                rep.Cookies = cook.GetCookies(rep.ResponseUri);
                
                cook.Add(rep.Cookies);
                Stream s = rep.GetResponseStream();//获取返回的数据流(字节序列)
                //****************将接收的数据读入内存***********************
                StreamReader sr = new StreamReader(s, Encoding.GetEncoding("gb2312"));
                html = sr.ReadToEnd();            sr.Close();
                s.Close();
                return html;
            }
            public void Start()
            {
                string postdata = "username=cwchyt&password=750112&CookieDate=0";
               string aa= req(postdata);
            }
      

  2.   

    HttpWebRequest  有自動跳轉的屬性
    frame 自己得到 source 之後,進行分析,再次 request 對應的 frame。