473,395 Members | 1,464 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,395 software developers and data experts.

Problems with NetworkCredientials in HttpWebRequest

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();)

}

The error I get is
System.Net.WebException: The operation has timed-out. at
System.Net.HttpWebRequest.GetResponse()

I've set the test.asp file to write out a text file if it receives a
POST request. Its getting nothing.

Thanks in advance for any help you can give.
Mark

Apr 18 '06 #1
1 1422
Why do you think that the trouble is with credentials?
AFAIK if credentials weren't okay then server would respond with 401 or 403
error.

Since, you get timeout, something is wrong with the network or server code
that is processing code.

Just a hint: do setup connection limit for ServicePoint?

By default maximum is set to 2 connections. That is if you have 2
connections and then issue request.GetResponse() - it is quite possible that
you'll receive timeout.

To increase maximum connection limit by 15 use following code
HttpWebRequest request;
//some code here
request.ServicePoint.ConnectionLimit = 15;

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

<mr*****@hotmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
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();)

}

The error I get is
System.Net.WebException: The operation has timed-out. at
System.Net.HttpWebRequest.GetResponse()

I've set the test.asp file to write out a text file if it receives a
POST request. Its getting nothing.

Thanks in advance for any help you can give.
Mark

Apr 18 '06 #2

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

Similar topics

3
by: Adam Stirk | last post by:
Hi, I am trying to download a image that is generated by PHP using HttpWebRequest, I believe the server uses cookies to generate the image, but I keep getting the error image from the server. ...
16
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the...
8
by: Peter Afonin | last post by:
Hello, I've created the domain registration system in ASP.NET. I'm using HttpWebRequest to post the data to the registrar's server. So in the Post string I'm passing the data like name, address,...
3
by: Sean Chapman | last post by:
ok, heres the problem.. i have an asp.net page that im using to kind of relay information back and forth. So on the Page_Load i make a request to a webservice and return some xml back to the first...
6
by: Oliver | last post by:
I have a very wired problem requesting one specific url from within my application. I have struggeled with this for 5 hours now, and searched google withour any luck, so i hope that someone are...
2
by: mroffey | last post by:
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?...
2
by: Tyler | last post by:
I am using httpwebrequest to do a screen scrape. This works great on my development box, but does not on the production box. Here is the code. Dim webRequest As HttpWebRequest =...
1
by: Sam | last post by:
Hi All, I'm trying to write a simple multi-threaded windows service application using ThreadPool and I'm running into the same problem as described by MS article:...
3
by: matadon | last post by:
Hi, I am writing a C# app. I have a finite (~50) set of URLs that I am continuously polling in a circular manner. I would like to do this in a way that can send out each of the requests and get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.