I am making requests to a web site that is using a SSL certificate. Therefore if I do:
var webClient = new WebClient();
webClient.DownloadData("https://link1"); // 1
webClient.DownloadData("https://link2"); // 2
In both scenarios I am exchanging public and private keys because webclient does not save session right?
Then I believe I need a WebClient class that is cookie aware. So I googled for that and I came up with: https://stackoverflow.com/a/11523836/637142
If I use that class and do:
var webClient2 = new WebClientEx(); // this class is on the link
webClient2.DownloadData("https://link1"); // 1
webClient2.DownloadData("https://link2"); // 2
Now I will not have to exchange public and private keys the second time right?
Anyways here is my problem now I need to be able to do:
var webClient2 = new WebClientEx(); // this class is on the link
Task.Fatory.StartNew(()=>
webClient2.DownloadData("https://link1"); // 1
);
Task.Fatory.StartNew(()=>
webClient2.DownloadData("https://link2"); // 2
);
That throws an exception because WebClient
can only download data at once. As a result I have done:
Task.Fatory.StartNew(()=>
new WebClient().DownloadData("https://link1"); // 1
);
Task.Fatory.StartNew(()=>
new WebClient().DownloadData("https://link2"); // 2
);
That works but its not efficient because for every request I will be exchanging public and private keys
PS: Note I know very little about SSL therefore please correct me if I assume something that is wrong. Perhaps SSL does not use a session in order to maintain symmetric keys. In other words I do not understand why only the first request in the web browser is the one that takes a long time. After the first request all are fast. I assume the symmetric key is stored in the session.