CookieContainer Returning NULL

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 99
Reputation: FTProtocol has a little shameless behaviour in the past 
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

CookieContainer Returning NULL

 
0
  #1
Feb 1st, 2009
Ok so it logs in fine using

  1. public bool Login()
  2. {
  3. string postdata = string.Format("m=login&nextURL=http%3A%2F%2Fwww.ijji.com%2Findex.nhn&memberid={0}&password={1}", encode(Username), encode(Password));
  4. string result = post(_url + "login.nhn", postdata);
  5. return !(result.Contains("You have entered an incorrect password") || result.Contains("User ID is not found"));
  6. }
  7. public string GetCookies() { return Cookies.GetCookieHeader(new Uri("http://ijji.com/")); }

then it when trying to get the cookies to an inside browser it errors

  1. if (Logins.Login())
  2. {
  3. IDC_Browse.Navigate("javascript:cookie=\"" + Logins.GetCookies() + "\";"); // <-- that line
  4. IDC_Browse.Navigate("javascript:goPlay('u_gunz', '');");
  5. }

the Logins.GetCookies(); is returning a null reference.

"NullReferenceException was caught"
"Object reference not set to an instance of an object."

Basically - i need it to store the cookies from the login and ship them into the C# web browser control then run that second lot of javascript

Any ideas?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: CookieContainer Returning NULL

 
0
  #2
Feb 2nd, 2009
But its not the same instance.. So, its not going to have the same cookies. You would need to grab and set the cookies at the time you login
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 99
Reputation: FTProtocol has a little shameless behaviour in the past 
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Re: CookieContainer Returning NULL

 
0
  #3
Feb 2nd, 2009
Originally Posted by LizR View Post
But its not the same instance.. So, its not going to have the same cookies. You would need to grab and set the cookies at the time you login
how?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: CookieContainer Returning NULL

 
0
  #4
Feb 2nd, 2009
Set the cookie when you make the login call..
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 99
Reputation: FTProtocol has a little shameless behaviour in the past 
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Re: CookieContainer Returning NULL

 
0
  #5
Feb 2nd, 2009
Originally Posted by LizR View Post
Set the cookie when you make the login call..
yeah............ I don't understand
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: CookieContainer Returning NULL

 
0
  #6
Feb 2nd, 2009
Thats obvious.
Did you cut and paste the code you have? You have a login function, you need to collect the cookies and store them within the login function..
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 99
Reputation: FTProtocol has a little shameless behaviour in the past 
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Re: CookieContainer Returning NULL

 
0
  #7
Feb 2nd, 2009
Originally Posted by LizR View Post
Thats obvious.
Did you cut and paste the code you have? You have a login function, you need to collect the cookies and store them within the login function..
ive only been coding in C# for around a month so i have no idea about cookies
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: CookieContainer Returning NULL

 
0
  #8
Feb 2nd, 2009
cookies are not a c# thing, but a web thing.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 99
Reputation: FTProtocol has a little shameless behaviour in the past 
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Re: CookieContainer Returning NULL

 
0
  #9
Feb 5th, 2009
Originally Posted by LizR View Post
cookies are not a c# thing, but a web thing.
yes what i meant is i have no idea how to keep them from the login and inject them into the webbrowser control so i can from there
execute javascript
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC