Problems with NetworkCredientials in HttpWebRequest

M

mroffey

Hi I'm using the code below to post to a web form, but when I run it, i
get System.Net.WebException: The operation has timed-out.
error

Obviously something is wrong, can anyone give me a clue?

string url = "http://localhost/testapp/test.asp";
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.Credentials = new NetworkCredential("username",
"password", null);
myHttpWebRequest.Method = "POST";
try
{
HttpWebResponse myHttpWebResponse =
(HttpWebResponse)myHttpWebRequest.GetResponse();
}
catch (Exception e)
{
Response.Write (e.ToString();)
}

Thanks in advance for any help you can give.
Mark
 
L

Leon Friesema

Hi I'm using the code below to post to a web form, but when I run it, i
get System.Net.WebException: The operation has timed-out.
error

Obviously something is wrong, can anyone give me a clue?

string url = "http://localhost/testapp/test.asp";
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create(url);
myHttpWebRequest.Credentials = new NetworkCredential("username",
"password", null);
myHttpWebRequest.Method = "POST";
try
{
HttpWebResponse myHttpWebResponse =
(HttpWebResponse)myHttpWebRequest.GetResponse();
}
catch (Exception e)
{
Response.Write (e.ToString();)
}

Thanks in advance for any help you can give.
Mark

Try posting String.Empty into the domain NetworkCredential

Leon
 
M

mroffey

No that didn't work. But thanks for the suggestion.I just realised I
didn't post the whole error message, but I guess that it won't help.
It is.
System.Net.WebException: The operation has timed-out. at
System.Net.HttpWebRequest.GetResponse()

I've set the password on the testapp directory to pass through as clear
text
 

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

Top