Hello, I am trying to use a WebBrowser control in a winform to allow a user to log in to a site, and then make HttpWebRequest using the cookie that is accepted. This procedure is suggested here: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/c8107e4d-fe8f-4be9-81a4-0575eb72248f/
However, when I try to access WebBrowser.Document.Cookie, I see that Cookie is null. The login proccess is seccesfull, as I can continue browsing the site while logged in, but Document.Cookie is null.
How can I get that cookie?
Thanks, Itay.
Check out my blog at http://blogs.microsoft.co.il/blogs/itaysk | Mark my post as helpful if I helped |
| Itay Shakury Sunday, July 12, 2009 6:55 AM |
using webbrowser you can load a certain page-navigate somewhere-automate login- get in- open some other page- grab data on that page etc. All this even without showing to user and without any interaction from user. try to search relevant to this in this forum. use DOM to access elements. you can do it like webbrowser1.document.getElementbyId("idForusernameTextBoxInPage").setAttribute("value","whatever you want") and invoke form's submit method after filling both textboxes like ......document.forms("formName").invokeMember("submit") try it, ask otherwise. and if you want help with that then please provide relevant source of that webpage.
Thanks
I AM OPTIMUS PRIME
- Marked As Answer byItay Shakury Wednesday, July 15, 2009 7:51 AM
-
|
| Omie Tuesday, July 14, 2009 6:13 PM |
Could you share the link of page you're trying to work with ? Open that page in internet explorer and login. then in IE's address bar enter javascript:alert(document.cookie); and press Enter key. Shows something ?
Thanks
I AM OPTIMUS PRIME
|
| Omie Sunday, July 12, 2009 7:04 AM |
Hi,
The page I'm trying to work with is my college's external login. It's in Hebrew, so I don't know if it will make sense to you, but it's a simple page where the top textbox is for the student ID, the second one is for password, and the button logs you in. http://www.mta.ac.il/mta/infostation/login/default.aspx
Anywany I am 100% sure I get a cookie, and If with document.cookie I cansee the cookie(as you suggested).
Any ideas?
Thanks, Itay.
Check out my blog at http://blogs.microsoft.co.il/blogs/itaysk | Mark my post as helpful if I helped |
| Itay Shakury Sunday, July 12, 2009 12:29 PM |
No. When I load page I get no cookies except aspSession. and I dont have login details, I cant see what happens when someone logs in. Are you trying to automate that page ? You can do it using webbrowser too. Little lengthy but it works. You can try that as alternative.
Thanks
I AM OPTIMUS PRIME
|
| Omie Sunday, July 12, 2009 1:56 PM |
Hi,
That ASP Session cookie is what I'm looking for.
What I'm trying to do is to get the asp session is, and then make subsequent requests using HttpWebRequest object and that session id.
Thanks for you help,
Itay.
Check out my blog at http://blogs.microsoft.co.il/blogs/itaysk | Mark my post as helpful if I helped |
| Itay Shakury Sunday, July 12, 2009 7:06 PM |
something is wrong. Now I dont get any cookie at all !!
Thanks
I AM OPTIMUS PRIME
|
| Omie Sunday, July 12, 2009 7:39 PM |
Is there another way to get the cookie? Is there a reason why I will get null cookie? Is there another way to do what I'm trying?
Thanks, Itay. Check out my blog at http://blogs.microsoft.co.il/blogs/itaysk | Mark my post as helpful if I helped |
| Itay Shakury Monday, July 13, 2009 9:22 AM |
No idea about first 2, for 3rd question, there is. You can use webbrowser control to achieve the same. I mean instead of stealing a cookie from webbrowser control, use the same control. You dont have to deal with cookies then.
Thanks I AM OPTIMUS PRIME |
| Omie Monday, July 13, 2009 10:47 AM |
Hi Omie, thanks for bearing with me.
I need to make an HttpWebRequest to a certain page, using the session ID stored in the cookie.
How can I do this without stealing the cookie?
Thanks,
Itay.
Check out my blog at http://blogs.microsoft.co.il/blogs/itaysk | Mark my post as helpful if I helped |
| Itay Shakury Tuesday, July 14, 2009 4:24 PM |
using webbrowser you can load a certain page-navigate somewhere-automate login- get in- open some other page- grab data on that page etc. All this even without showing to user and without any interaction from user. try to search relevant to this in this forum. use DOM to access elements. you can do it like webbrowser1.document.getElementbyId("idForusernameTextBoxInPage").setAttribute("value","whatever you want") and invoke form's submit method after filling both textboxes like ......document.forms("formName").invokeMember("submit") try it, ask otherwise. and if you want help with that then please provide relevant source of that webpage.
Thanks
I AM OPTIMUS PRIME
- Marked As Answer byItay Shakury Wednesday, July 15, 2009 7:51 AM
-
|
| Omie Tuesday, July 14, 2009 6:13 PM |
Will try it. Thanks. Check out my blog at http://blogs.microsoft.co.il/blogs/itaysk | Mark my post as helpful if I helped |
| Itay Shakury Wednesday, July 15, 2009 7:51 AM |