Hi - Simple question ahead!
STATUS:
I've come this far I've implemented a solution where I get a cookie with a session, but it still doesn't work. In the sniffer tool, I can see the difference between my application and when using the real website as this:
REAL: ASPSESSIONIDSCRAASDB=EFFBFPEAKOBJGLAPNABPLLCB; passes=15; ChatCannel=1
PROGRAM: ASPSESSIONIDSCRAASDB=KPGBFPEAHNDLENDEOAEELMPJ
The program acts like it's not logged in, even though I've stored the session as a cookie..
I'm trying to create a small program, helping me playing a niche Internet game (just calculations and stuff)..
Anyway - I need to log in! The login system is based on sessions ..
So... I've tried this:
string url = "http://server1.online-trucker.dk";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
StreamWriter post = new StreamWriter(req.GetRequestStream());
post.Write("Username=MyUsername&Password=MyPassword");
post.Close();
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
resp.GetResponseStream();
string kage = GetContentFromStream(resp.GetResponseStream());
Being a little naive, I expect "kage" should contain the response after clicking the "Log in" button, and my little crawler should have logged in.
The HTML I'm playing with:
Brugernavn:
<input type="text" name="Username" size="10" STYLE="font-size: 10px; background-color: #CCCCCC; border: 1px solid #666666;">
Kode:<input type="password" name="Password" size="10" STYLE="font-size: 10px; background-color: #CCCCCC; border: 1px solid #666666;">
<input type="submit" name="Logind" value="Logind" STYLE="font-size: 10px; background-color: #CCCCCC; border: 1px solid #666666;">
But if you have just a little knowledge about WebRequest, I'm sure you by now will laugh ! :-)
What I want to do:
- Put in username/password
- Click "Log ind"
- Be able to play in the whole domain of the site, with the now active session
I really hope someone will help!