Through my application, I'm using WebClient
to access files online and processing them. Here is one such example:
using (var webClient = new WebClient())
{
webClient.Credentials = new NetworkCredential(userName, password, domain);
var bytes = webClient.DownloadData(urlToWorkbook);
Stream stream = new MemoryStream(bytes);
var workbook = new Workbook(stream);
stream.Close();
stream.Dispose();
return workbook;
}
When I was developing the application and testing through Visual Studio's debugger, everything worked fine. Now that I've deployed the application and it's running through IIS, I get the following error on the webClient.DownloadData()
call:
System.Net.WebException: An exception occurred during a WebClient request. System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
EDIT: Another strange thing is that when I put this code on my controller's Index action (this is an MVC) app, it executes the DownloadData() call successfully everything. It is only when the call is embedded in my application (where it's needed) that it fails.
I published my site locally to my machine's IIS and I get the same exception. I feel like I've tried a million code solutions. It would seem it's a difference between VS's web server and IIS. Any idea of what I could do in IIS?
WebClient
communication process? – Dennis R