setting timeout of a post in c#

Posted on 2009-02-10
Last Modified: 2013-12-17
Im trying to specify a timeout length of the following code.  Like if it takes more than 7 seconds, then stop processing or something, and throw a TimeoutException or something.  Does anybody know how to do that?
public string ProcessHttpPost(string url)



            WebClient client = new WebClient();            

            byte[] bResponse = client.UploadValues(url, "POST", this.Values);

            return Encoding.ASCII.GetString(bResponse);


Open in new window

Question by:rodmjay
    LVL 8

    Expert Comment

    On the web.config file you can change the timeout duration on seconds.

    LVL 15

    Accepted Solution

    client.Timeout = 60000; //(Required timeout milliseconds)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my 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…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now