Please help::Not able to Login using WebRequest/WebResponse

G

Guest

I am using the code below to login to a password requiring website
programatically. I keep getting back the logon page. I have read some posts
here and haven't found a working solution still. I don't need any proxy to
connect. After seeing some posts I eeven added a cookie container, still
doesn't work.I'd really appreciate a lot, if someone could tell me what
additional code is required to make this work
Thanks in advance,
Naga
-*****************************************************
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create(txtUrl.Text.Trim());
myRequest.Method = "POST";
myRequest.CookieContainer = new CookieContainer(); // enable cookies

NetworkCredential networkCredential = new NetworkCredential(strName,
strPwd);
// Associate the 'NetworkCredential' object with the 'WebRequest'
object.
myRequest.Credentials = networkCredential;

//System.Net.WebResponse myWebResponse = myRequest.GetResponse();
HttpWebResponse myWebResponse =
(HttpWebResponse)myRequest.GetResponse();
StreamReader sr = new
StreamReader(myWebResponse.GetResponseStream(), Encoding.ASCII);
txtResult.Text = sr.ReadToEnd();
-*****************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top