473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Form Post via HttpWebRequest

Hello,

I am trying to automatically login to websites after I have used SSO to get
the credentials. For my test, I am working with my Yahoo account. The code
that I am using is code that many have said works fine. I have done some
tweaking to fit my specific needs. The Problem is when I post to the My
Yahoo login page, the apparently the user name and password are being passed
because my user name is accepted, but I am told that there is an INVALID
PASSWORD. I know the password is correct because I use the account all the
time. Has anyone had this problem? Can anyone help me? Thank you in
advance.

Tony

Here is the code I am using:

void Page_Load(object sender, EventArgs e) {

string appURL = "http://login.yahoo.com/config/login";
string strPostData = String.Format("login={0}&password={1}",
"myloginname", "mypassword");

// Setup the http request.
HttpWebRequest wrWebRequest = WebRequest.Create(appURL) as
HttpWebRequest;
wrWebRequest.Method = "POST";
wrWebRequest.ContentLength = strPostData.Length;
wrWebRequest.ContentType = "application/x-www-form-urlencoded";
wrWebRequest.CookieContainer = new CookieContainer();

// Post to the login form.
StreamWriter swRequestWriter = new
StreamWriter(wrWebRequest.GetRequestStream());
swRequestWriter.Write(strPostData);
swRequestWriter.Close();

// Get the response.
HttpWebResponse hwrWebResponse =
(HttpWebResponse)wrWebRequest.GetResponse();

// Have some cookies.
CookieCollection ccCookies = hwrWebResponse.Cookies;

// Read the response
StreamReader srResponseReader = new
StreamReader(hwrWebResponse.GetResponseStream());
string strResponseData = srResponseReader.ReadToEnd();
srResponseReader.Close();

// Display the response.
Response.Write(strResponseData);
}
Nov 23 '05 #1
3 31644
Never mind. I figured it out.

Tony

"Tony Hunter" <to*********@misi.com> wrote in message
news:#V*************@TK2MSFTNGP10.phx.gbl...
Hello,

I am trying to automatically login to websites after I have used SSO to get the credentials. For my test, I am working with my Yahoo account. The code that I am using is code that many have said works fine. I have done some
tweaking to fit my specific needs. The Problem is when I post to the My
Yahoo login page, the apparently the user name and password are being passed because my user name is accepted, but I am told that there is an INVALID
PASSWORD. I know the password is correct because I use the account all the time. Has anyone had this problem? Can anyone help me? Thank you in
advance.

Tony

Here is the code I am using:

void Page_Load(object sender, EventArgs e) {

string appURL = "http://login.yahoo.com/config/login";
string strPostData = String.Format("login={0}&password={1}",
"myloginname", "mypassword");

// Setup the http request.
HttpWebRequest wrWebRequest = WebRequest.Create(appURL) as
HttpWebRequest;
wrWebRequest.Method = "POST";
wrWebRequest.ContentLength = strPostData.Length;
wrWebRequest.ContentType = "application/x-www-form-urlencoded";
wrWebRequest.CookieContainer = new CookieContainer();

// Post to the login form.
StreamWriter swRequestWriter = new
StreamWriter(wrWebRequest.GetRequestStream());
swRequestWriter.Write(strPostData);
swRequestWriter.Close();

// Get the response.
HttpWebResponse hwrWebResponse =
(HttpWebResponse)wrWebRequest.GetResponse();

// Have some cookies.
CookieCollection ccCookies = hwrWebResponse.Cookies;

// Read the response
StreamReader srResponseReader = new
StreamReader(hwrWebResponse.GetResponseStream());
string strResponseData = srResponseReader.ReadToEnd();
srResponseReader.Close();

// Display the response.
Response.Write(strResponseData);
}

Nov 23 '05 #2
Tony, so tell us.... What did it take to get it to work?

Alex

"Tony Hunter" wrote:
Never mind. I figured it out.

Tony

"Tony Hunter" <to*********@misi.com> wrote in message
news:#V*************@TK2MSFTNGP10.phx.gbl...
Hello,

I am trying to automatically login to websites after I have used SSO to

get
the credentials. For my test, I am working with my Yahoo account. The

code
that I am using is code that many have said works fine. I have done some
tweaking to fit my specific needs. The Problem is when I post to the My
Yahoo login page, the apparently the user name and password are being

passed
because my user name is accepted, but I am told that there is an INVALID
PASSWORD. I know the password is correct because I use the account all

the
time. Has anyone had this problem? Can anyone help me? Thank you in
advance.

Tony

Here is the code I am using:

void Page_Load(object sender, EventArgs e) {

string appURL = "http://login.yahoo.com/config/login";
string strPostData = String.Format("login={0}&password={1}",
"myloginname", "mypassword");

// Setup the http request.
HttpWebRequest wrWebRequest = WebRequest.Create(appURL) as
HttpWebRequest;
wrWebRequest.Method = "POST";
wrWebRequest.ContentLength = strPostData.Length;
wrWebRequest.ContentType = "application/x-www-form-urlencoded";
wrWebRequest.CookieContainer = new CookieContainer();

// Post to the login form.
StreamWriter swRequestWriter = new
StreamWriter(wrWebRequest.GetRequestStream());
swRequestWriter.Write(strPostData);
swRequestWriter.Close();

// Get the response.
HttpWebResponse hwrWebResponse =
(HttpWebResponse)wrWebRequest.GetResponse();

// Have some cookies.
CookieCollection ccCookies = hwrWebResponse.Cookies;

// Read the response
StreamReader srResponseReader = new
StreamReader(hwrWebResponse.GetResponseStream());
string strResponseData = srResponseReader.ReadToEnd();
srResponseReader.Close();

// Display the response.
Response.Write(strResponseData);
}


Nov 23 '05 #3
Here is the solution...try it

replace the part of your code by (not 'password'...will be 'passwd') -

string strPostData = String.Format("login={0}&passwd={1}",
"myloginname", "mypassword");

Enjoy !!!

Hello,

I am trying to automatically login to websites after I have used SSO to get
the credentials. For my test, I am working with my Yahoo account. The code
that I am using is code that many have said works fine. I have done some
tweaking to fit my specific needs. The Problem is when I post to the My
Yahoo login page, the apparently the user name and password are being passed
because my user name is accepted, but I am told that there is an INVALID
PASSWORD. I know the password is correct because I use the account all the
time. Has anyone had this problem? Can anyone help me? Thank you in
advance.

Tony

Here is the code I am using:

void Page_Load(object sender, EventArgs e) {

string appURL = "http://login.yahoo.com/config/login";
string strPostData = String.Format("login={0}&password={1}",
"myloginname", "mypassword");

// Setup the http request.
HttpWebRequest wrWebRequest = WebRequest.Create(appURL) as
HttpWebRequest;
wrWebRequest.Method = "POST";
wrWebRequest.ContentLength = strPostData.Length;
wrWebRequest.ContentType = "application/x-www-form-urlencoded";
wrWebRequest.CookieContainer = new CookieContainer();

// Post to the login form.
StreamWriter swRequestWriter = new
StreamWriter(wrWebRequest.GetRequestStream());
swRequestWriter.Write(strPostData);
swRequestWriter.Close();

// Get the response.
HttpWebResponse hwrWebResponse =
(HttpWebResponse)wrWebRequest.GetResponse();

// Have some cookies.
CookieCollection ccCookies = hwrWebResponse.Cookies;

// Read the response
StreamReader srResponseReader = new
StreamReader(hwrWebResponse.GetResponseStream());
string strResponseData = srResponseReader.ReadToEnd();
srResponseReader.Close();

// Display the response.
Response.Write(strResponseData);
}
May 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: james | last post by:
How can I have a php script send data to a URL as form post data from within the script without creating an actual form in a web page. I am working with an affiliate program (from Affiliateshop)...
1
by: Jeremy Phillips | last post by:
I am trying to build a web form that uses the "POST" method (too much data for GET) to send data to a second form, then displays the response of that form post. The second web form requires...
2
by: | last post by:
Hi everyone, I'm using VS.NET, Framework 1.1, Windows 2000 Server, IIS 5, all the latest patches are installed. Im having this wierd random problem, that I cannot reproduce but it happens...
4
by: Al Cadalzo | last post by:
I'm trying to simulate a form post (i.e. Method="POST"). The FORM POST I'm trying to simulate is similar to this: <FORM NAME=SearchForm METHOD=POST ACTION=Search> <SELECT name="criteriaA" >...
4
by: Ron Vecchi | last post by:
I know this has messiness written all over it but I have a question about using HttpWebRequest/Response to essentially spider a website and post information to the forms. The (very) basic goal is...
1
by: guoqi zheng | last post by:
I know in webclient class, there is a possibility to post form data to a remote url, but how can I not only just post, I need to redirect user to that page as well. So what I want is just like a...
1
by: John Braham | last post by:
I have a slight wall headbutter which I'm hoping someone will have an idea for (I'd be very grateful!). Basically I'm trying to make a form post to an asp page programatically from within VB.NET...
10
by: eggie5 | last post by:
Is it possible to get a file without using a form post? I want to get the data (bytes) of a file, text or binary, and just save it to a variable. Similar to the post body of a form that has a...
0
by: shlim | last post by:
Currently I'm using VB.Net to perform a http/https multipart form post to a servlet. I'm able to perform the post using HttpWebrequest via GetRequestStream(). However, the servlet returned me with...
0
by: magix | last post by:
Hi, I launched a modal popup window with code like: <script language="javascript"> function modalWin() { if (window.showModalDialog) { window.showModalDialog("MyPage1.asp","MyPopup",...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.