Search code examples
c#.nethttpwebrequestclone

How to Clone HttpWebRequest?


I want to set some properties of an HttpWebRequest and then download some files asynchronously. However, I need one copy of HttpWebRequest for each download, so how can I clone it so that I don't have to copy each property "by hand"?


Solution

  • HttpWebRequest does not support serialization or cloning, thus you have to implement your own mechanism to save/copy it. You can use serialized (or clonable) derived class or some wrapper for this task.