Partilhar via


How to troubleshoot your System.Net code

Sytem.Net tracing
One of the easiest ways is to use the built in System.Net tracing. It is a matter of copiying a config file to your machine and re-running your application. Here is a very detailed article on how tracing works and how to enable it.
https://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx

NetMon capture 
The other way is to sniff the network traffic using NetMon, Ethereal, or etc. Here is how you can do it with NetMon
https://blogs.msdn.com/dgorti/archive/2005/10/29/486887.aspx

Comments

  • Anonymous
    December 27, 2009
    How to i upload file using ftp url in vb.net 1.1? For example i need to upload file to "ftp://123.45.67.8" then how to do that. I tried using WebClient's UploadFile method but received an error "URI formats are not supported". Please help me in this regard. Thanks and regards, Govind

  • Anonymous
    January 05, 2010
    Govind, FTP uploads/downloads were not supported in .Net 1.1.  That support was added in 2.0.

  • Anonymous
    January 05, 2010
    Thanks for your reply Chrross. The site on which i am working running on 3 servers serverA, serverB and serverC. Our client has bought a new server serverD and made the serverD as a shared drive so that it is accessible through serverA, serverB and serverC. I have been assigned the task to upload documents to the shared drive from all the three servers. How can i achieve this in .NET 1.1? Thanks and regards, Govind

  • Anonymous
    January 06, 2010
    If you have shared drives that are accessable through windows explorer then you don't need networking APIs to do the copy, just file APIs.  I suggest File.Copy: http://msdn.microsoft.com/en-us/library/system.io.file.copy(VS.71).aspx With this you can used mapped drives (z:dirfile.txt) or full paths (\serversharedirfile.txt). Also look at the directory class for listing files: http://msdn.microsoft.com/en-us/library/system.io.directory_members(VS.71).aspx

  • Anonymous
    January 06, 2010
    Thanks Chrross, I will try this and will let you know if it works. Thanks, Govind

  • Anonymous
    March 08, 2011
    // Get the object used to communicate with the server.       string filename = "";       FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftppath /filename);       //request.Method = WebRequestMethods.Ftp.UploadFile;       request.Method = WebRequestMethods.Ftp.AppendFile;       // This example assumes the FTP site uses anonymous logon.       //request.Credentials = new NetworkCredential(username,password);       request.UsePassive = true;       request.UseBinary = true;       request.KeepAlive = false;       // Copy the contents of the file to the request stream. ;       string path = HTTPDatasheetPath()/filename;       WebRequest req = WebRequest.Create(path);       WebResponse response = req.GetResponse();       Stream _FileStream = response.GetResponseStream();       byte[] _Buffer = null;       // attach filestream to binary reader       System.IO.BinaryReader _BinaryReader = new System.IO.BinaryReader(_FileStream);       // get total byte length of the file       //long _TotalBytes = _FileStream.Read(_Buffer, 0, _Buffer.Length);        //new System.IO.FileInfo(path).Length;       long _TotalBytes = (long)response.ContentLength;       // read entire file into buffer       _Buffer = _BinaryReader.ReadBytes((Int32)_TotalBytes);       // close file reader       request.ContentLength = _Buffer.Length;       Stream requestStream = request.GetRequestStream();       requestStream.Write(_Buffer, 0, _Buffer.Length);       requestStream.Close();