Connecting Tech Pros Worldwide Forums | Help | Site Map

Reading Cookies from windows application

Newbie
 
Join Date: Jan 2008
Posts: 16
#1: May 13 '08
Hi All,
I am developing a download manager for a a website downloads.The problem is , I have to login in my windows application with same user credentials of web login when I logging in web application.In web application , I set cookies with user credentials ; but, Not able to read them in windows.I have tried the ideas suggested by http://p2p.wrox.com/topic.asp?TOPIC_ID=29325 .
I am not able to read the cookies created in Firefox while scanning cookie folder.When I am trying to read through HttpRequest , It only returns the ASP_net cookie.
How do I capture the credential of web login from my desktop application.Please Help Me.

Regards,
Preethi

Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#2: May 13 '08

re: Reading Cookies from windows application


Couldn't you just set your own?
When I use HttpWebRequest, I can see the cookies that are trying to be created and keep track of them.


Or are you trying to use "already logged in" user information, aka snooping through the cookies stored by the browser already?
Newbie
 
Join Date: Jan 2008
Posts: 16
#3: May 13 '08

re: Reading Cookies from windows application


Hi,
I am trying to use HttpWebReques.while using the code,
Expand|Select|Wrap|Line Numbers
  1.  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  2.  request.CookieContainer = new CookieContainer();
  3.  HttpWebResponse response = (HttpWebResponse) request.GetResponse();
  4.  response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
  5.  
  6.  
It seems that It creates a new request to URL and hence no one is logged in through this code; so, no cookie for user credentials is created and am not getting such a cookie.From Here , How do I proceed ?.please help me.

Thanks with anticipation,
Preethi.
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#4: May 13 '08

re: Reading Cookies from windows application


You can use the HttpWebReuest to log in. Get the user credentials from the user (texboxes?) Then go through the login motions and receive the cookie from the response object. Then just make sure to keep that cookie in all your requests?
Newbie
 
Join Date: Jan 2008
Posts: 16
#5: May 14 '08

re: Reading Cookies from windows application


Hi Plater,
Thank you for your quick replies.I Got your point of "Using user credentials for all logins".but, the problem is,I want to auto login in my windows application when web page gives some download links.at that time ,my windows application (Download Manager) has to log in and display previous downloads of the user . I have created a window service which is identifying a download link clicked and invoke the windows application.I works the fine if user credential are not needed (without any auto login).Now, I want auto login with user credentials. Is there any other way that a web page to leave some user credential in a client system (such as file,XML ) and captured by a windows application?.

Thanks,
Preethi
Nitin646's Avatar
Member
 
Join Date: Oct 2007
Location: मुंबई, India
Posts: 109
#6: May 14 '08

re: Reading Cookies from windows application


Quote:

Originally Posted by Plater

You can use the HttpWebReuest to log in. Get the user credentials from the user (texboxes?) Then go through the login motions and receive the cookie from the response object. Then just make sure to keep that cookie in all your requests?

Yo, plater bro,
Can you post some example for loging into website using above method??
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#7: May 14 '08

re: Reading Cookies from windows application


Ah ok, you have your program working in tandum with the browser.
So when a user is at a site and clicks a link to download, your pogram popups up and goes through the motions of downloading it?

Did you install your services to act as a web proxy? If so, user credentials will be sent to the proxy device and can be read from the user request that gets sent to it.

As for retreiving user credentials in your situation, without getting to see the full original request, I'm stumped at the moment.
Reply