I\'m trying to log onto a website by providing my (correct) username and password.
Here\'s the code:
string URL = @\"https://www.t-mobile.co.
You could try adding a user agent, like:
client.Headers.Add("user-agent", "your user agent here");
Sometimes web sites want to assure that a certain browser is used and/or pretends to be human.
I see 1 initial problem, you are posting back to the page url and not the submit URL (which has a session ID on it, and in my code I'd be checking for a valid session ID). There is also a javascript function called prior to the submit 'processSaveUserCh()' which is creating a cookie for the username. The omission of any of this may be preventing your successful login, it's an experiment and discover exercise I'm afraid.
This is posted on server if you try to login in browser:
org.apache.struts.taglib.html.TOKEN=81243ce1a02ff285745f7c25b86234a9&showLogin=true&upgrade=&username=username&password=password&submit=Log+in
Try adding those values as well, and figure out how TOKEN is generated.
EDIT: Check if cookies that page gives you are submited back too.
ANOTHER EDIT: Too see what is going on between server and browser (=Firefox) when you are making a request or posting data use LiveHttpHeaders addon.
Also I notice that you are creating a new CookieContainer each time you create your CookieAwareClientn class. This means that your cookies are not being saved between requests. Make that member static, so that you use the same cookiecontainer always.
Also like other said, you will have to experiment. WHat I do is, I download and install Firebug, and see how the request/response is beingn sent by the browser, along with the headers, etc. I then duplicate the same request using HttpWebRequest/WebClient.