943,553 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 2107
  • C# RSS
Feb 1st, 2009
0

CookieContainer Returning NULL

Expand Post »
Ok so it logs in fine using

C# Syntax (Toggle Plain Text)
  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

c# Syntax (Toggle Plain Text)
  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?
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008
Feb 2nd, 2009
0

Re: CookieContainer Returning NULL

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
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Feb 2nd, 2009
0

Re: CookieContainer Returning NULL

Click to Expand / Collapse  Quote originally posted by LizR ...
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?
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008
Feb 2nd, 2009
0

Re: CookieContainer Returning NULL

Set the cookie when you make the login call..
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Feb 2nd, 2009
0

Re: CookieContainer Returning NULL

Click to Expand / Collapse  Quote originally posted by LizR ...
Set the cookie when you make the login call..
yeah............ I don't understand
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008
Feb 2nd, 2009
0

Re: CookieContainer Returning NULL

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..
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Feb 2nd, 2009
0

Re: CookieContainer Returning NULL

Click to Expand / Collapse  Quote originally posted by LizR ...
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
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008
Feb 2nd, 2009
0

Re: CookieContainer Returning NULL

cookies are not a c# thing, but a web thing.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Feb 5th, 2009
0

Re: CookieContainer Returning NULL

Click to Expand / Collapse  Quote originally posted by LizR ...
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
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Updating StreamReader
Next Thread in C# Forum Timeline: how to refer the external file to my c# object





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC