By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,327 Members | 2,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,327 IT Pros & Developers. It's quick & easy.

Authentication and POST with C#

P: 3

I have been searching the internet about methods for a C# console program to login and post on a website.

I have been advised to either make the program log in every time when is necessary or to somehow include the session cookies with which I am logged in with my browser.

I am afraid though that some of the methods don't work with every website and specifically with those I need like

This is the login page that I have already got past with my browser but in order the program to authenticate I think it needs the cookies or to login itself

And the string I need to be posted is a known password string of 6 characters in the field "userpwd" or any of the link accessed from this page

Can anyone who has experience in this please give me a hint of what works with such kind of sites and with this one particularly and suggest what functions I should use? And any guidance of the best method to proceed is much appreciated.

Jan 29 '09 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 9,731
You need to look into using HttpWebRequest Object to make a request to the web page.

Please note that forms authentication uses authentication and session cookies to work. If these are missing then you cannot provide the login credentials to the page after the user has logged in. You need to capture the cookies issued by the page. You should look into how to use the CookieContainer to capture cookies.
Feb 11 '09 #2

P: 3
Yes thanks i used HttpWebRequest and HttpWebResponse to get the cookie as a string and then applying that cookie with Headers.Add for the POST request to work from my name.
Feb 11 '09 #3

Expert Mod 5K+
P: 9,731
I'm glad you got this working :)
Feb 11 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.