首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c# 怎么模拟登陆后操作

2013-06-25 
c# 如何模拟登陆后操作c# 如何模拟登陆后操作这段代码 在不需要登陆的页面操作没有问题 但需要登陆的页面

c# 如何模拟登陆后操作
c# 如何模拟登陆后操作
这段代码 在不需要登陆的页面操作没有问题 但需要登陆的页面 就不行 不知道该如何修改请教了


               HttpWebRequest request = null;
               HttpWebResponse response = null;
               //CookieContainer cc = new CookieContainer();
               request = (HttpWebRequest)WebRequest.Create(loginUrl);
               request.Method = "POST";
               request.ContentType = "application/x-www-form-urlencoded";
               byte[] postdatabyte = Encoding.UTF8.GetBytes(postdata);
               request.ContentLength = postdatabyte.Length;
               request.AllowAutoRedirect = false;
               //request.CookieContainer = cc;
               request.KeepAlive = true;
               Stream stream;
               stream = request.GetRequestStream();
               stream.Write(postdatabyte, 0, postdatabyte.Length);
               stream.Close();

[解决办法]
要想保持登录,需要附加上服务器给你的cookie
[解决办法]
Cookie问题,如果是登录的话,一定伴随的Cookie的

热点排行