Note that there are some explanatory texts on larger screens.

plurals
  1. POfile upload error
    text
    copied!<p>Here is my code at both client side and server side. My code is simple, just upload a file to an ASP.Net web site.</p> <p>My client code throws exception when it works on Vista (x64, Enterprise, SP1), but works fine on Windows Server 2003.</p> <p>Any ideas?</p> <p>10.10.12.162 is my server address.</p> <p>[Code] Client:</p> <pre><code> static void Main(string[] args) { Console.Write("\nPlease enter the URI to post data to : "); String uriString = Console.ReadLine(); WebClient myWebClient = new WebClient(); Console.WriteLine("\nPlease enter the fully qualified path of the file to be uploaded to the URI"); string fileName = Console.ReadLine(); Console.WriteLine("Uploading {0} to {1} ...", fileName, uriString); DateTime begin = DateTime.Now; byte[] responseArray = null; try { responseArray = myWebClient.UploadFile(uriString, fileName); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.ToString()); } DateTime end = DateTime.Now; Console.WriteLine("Elapsed time is: {0}", (end - begin).TotalMilliseconds); } </code></pre> <p>Server:</p> <pre><code>public partial class FileUploadHandler : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { foreach (string f in Request.Files.AllKeys) { HttpPostedFile file = Request.Files[f]; file.SaveAs("D:\\UploadFile\\UploadedFiles\\" + file.FileName); } } } </code></pre> <p>Exception from client side:</p> <p>Unable to connect to the remote server System.Net.WebException: Unable to connect to the remote server ---> System.Net. Sockets.SocketException: No connection could be made because the target machine actively refused it 10.10.12.162:1031 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre ss socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock et s4, Socket s6, Socket&amp; socket, IPAddress&amp; address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception&amp; exception) --- End of inner exception stack trace --- at System.Net.WebClient.UploadFile(Uri address, String method, String fileNam e) at FileUploadClient.Program.Main(String[] args) in D:\UploadFile\FileUploadClient\Program.cs:line 30 [/Code]</p> <p>regards, George</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload