C#-在Webbrowser控件中使用会话cookie进行导航 [英] c# - navigate with session cookie in webbrowser control

查看:70
本文介绍了C#-在Webbrowser控件中使用会话cookie进行导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi

我正在使用Win-from Web浏览器控件登录到ASP经典站点并浏览页面.我可以进行身份​​验证,并成功登录到登录页面后.但是之后,我要打开的任何其他页面会将我重定向到登录页面!请 帮助!有什么问题?!我认为问题在于会话cookie!如何存储和使用会话cookie ?!

我的代码:

   

hi

I am using win-from web browser control to login to an ASP classic site and navigate through pages. I am able to do authentication and successfully move to after login page. but after then any other page that I want to Open redirects me to login page!! Please help! what is the problem?!!  I thins the problem is session cookie! how can I store and use session cookie?!

my code:

   

private void button1_Click(object sender, EventArgs e)
   {   
     mshtml.HTMLDocument myDoc =(mshtml.HTMLDocument)webBrowser1.Document.DomDocument;
     
     HTMLInputElement username = (HTMLInputElement)myDoc.all.item("username", 0);
     username.value = textBox2.Text;


     HTMLInputElement password = (HTMLInputElement)myDoc.all.item("password", 0);

     password.value = textBox3.Text;


     HTMLInputElement btnsubmit = (HTMLInputElement)myDoc.all.item("submit", 0);
     btnsubmit.click();

     while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
     {
        Application.DoEvents();
        status.Text = "Waiting for web to response";
     }
     webBrowser1.AllowNavigation = true;
     status.Text = "Finish";

     if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
     {
       webBrowser1.Navigate("login required url");
     }
   }


推荐答案

嗨.

您是否检查了POST/GET的外观?

Did you check how the POST /GET looks like?

也许还有其他隐藏的参数/字段被提交.

Maybe there are other hidden parameters / fields that are submitted.

为了检查是否使用了Microsoft的Fiddler:

In order to check that use Microsoft's Fiddler:

http://www.fiddler2.com/Fiddler2/version.asp

 

Noam B
_________________________________________________________

请不要忘记回答/帮助投票.鼓励我们为您提供帮助...

Noam B
_________________________________________________________

Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you...


这篇关于C#-在Webbrowser控件中使用会话cookie进行导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆