Solved

Timeout httpwebrequest

Posted on 2008-06-11
1
643 Views
Last Modified: 2012-05-11
Hello I am calling a web service with the following code:

1                Dim postData As String
2                Dim encoding As ASCIIEncoding
3                Dim viaRequest As HttpWebRequest = WebRequest.Create("http://72.222.111.00/WebService/WebService.asmx/RequestSnapshot?")
4                postData = "URLRequested=" & URLRequested & "&imageFileName=" & imageFileName & "&CaptureType=Realtime"
5                viaRequest.Method = "POST"
6                viaRequest.ContentType = "application/x-www-form-urlencoded"
7                viaRequest.ContentLength = postData.Length
8                viaRequest.Timeout = "15000"
9    
10               Dim writer As StreamWriter = New StreamWriter(viaRequest.GetRequestStream)
11               writer.Write(postData.ToString)
12               writer.Close()
13  
14               Dim r As HttpWebResponse = viaRequest.GetResponse
15               Dim reader As New StreamReader(r.GetResponseStream)
16               Dim respPage As String = reader.ReadToEnd

 

How can I process some code IF the request takes more than 15 seconds.  I do have a timeout set of 15 seconds but it will not work becuase It will end the request after 15 seconds.  What I would like to accomplish is to process some other code if the request takes longer than 15 seconds but without ending the request to the web service as timeout does.  How can i do this?

 

Thanks Very Much!!
0
Comment
Question by:grogo21
1 Comment
 
LVL 25

Accepted Solution

by:
apeter earned 500 total points
ID: 21762892
May Be you can set the maximum timeout so that your request never fails. In the same method you can have timer function which is trigers after 15 seconds. If you get the response in 15 seconds then you deactivate your timer function.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question