Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to set the TIMEOUT property of WebClient class???

How to set the TIMEOUT property of WebClient class???

Scheduled Pinned Locked Moved C#
csharptutorialquestion
4 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Small Rat
    wrote on last edited by
    #1

    :confused:I use C# to develop a web embed application, and I find that using WebClient is very easy to raise a web request and get the response. But I don' know how to set the TIMEOUT property(or something like that) to prolong the request time.

    C 1 Reply Last reply
    0
    • S Small Rat

      :confused:I use C# to develop a web embed application, and I find that using WebClient is very easy to raise a web request and get the response. But I don' know how to set the TIMEOUT property(or something like that) to prolong the request time.

      C Offline
      C Offline
      Chris Jobson
      wrote on last edited by
      #2

      The System.Net.WebRequest class has a Timeout property, which is a value in milliseconds or System.Threading.Timeout.Infinite. See http://www.dotgnu.org/pnetlib-doc/System/Net/WebRequest.html[^] for more details of the class. Chris Jobson

      S 1 Reply Last reply
      0
      • C Chris Jobson

        The System.Net.WebRequest class has a Timeout property, which is a value in milliseconds or System.Threading.Timeout.Infinite. See http://www.dotgnu.org/pnetlib-doc/System/Net/WebRequest.html[^] for more details of the class. Chris Jobson

        S Offline
        S Offline
        Small Rat
        wrote on last edited by
        #3

        You mean I cann't use WebClient anymore(I have to use WebRequest and WebResponse instead)???? Do you know some resolution that can extend the functionality of WebClient and realize the function I need? Tnanks.

        C 1 Reply Last reply
        0
        • S Small Rat

          You mean I cann't use WebClient anymore(I have to use WebRequest and WebResponse instead)???? Do you know some resolution that can extend the functionality of WebClient and realize the function I need? Tnanks.

          C Offline
          C Offline
          Chris Jobson
          wrote on last edited by
          #4

          Sorry, I thought that WebClient had a way to access the WebRequest that it was using internally - but I was wrong, so maybe you will have to use WebRequest/WebResponse:(. The only other idea I have is that if you know in advance the URLs you will be accessing you could use WebRequest.RegisterPrefix to register a class of your own (for just the URL you want) that implements the IWebRequestCreate interface, and that class could return an instance of one of the standard WebRequest objects (e.g. an HttpWebRequest) with the timeout set to whatever you want. See the web page I referenced in my previous answer for more details. However, I must stress that I haven't tried this, and it's based only on my understanding of the information on the www.dotgnu.org website. Good luck! Chris Jobson

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups