Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

The underlying connection was closed: The server committed a protocol violation.

$
0
0
I'm testing out server 2012 R2 but I'm having a problem with some code using the FtpWebRequest class, I'm getting this server committed a protocol violation error.  It works fine on my 2008 R2 server but I can't get it to work on 2012.  I looked at the .NET files for this class and the sizes are different, they're larger on 2012.  Anyone have a clue what might be the problem?  Here's my code:

Protected Sub Upload_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim UploadTo As String = "ftp://mydomain.com/test.txt"
        Dim ftp As FtpWebRequest = DirectCast(WebRequest.Create(UploadTo), FtpWebRequest)
        ftp.Credentials = New System.Net.NetworkCredential("username", "password")
        ftp.KeepAlive = True
        ftp.Method = WebRequestMethods.Ftp.UploadFile
        Dim file() As Byte = System.IO.File.ReadAllBytes(Server.MapPath("/test.txt"))
        Dim stream As System.IO.Stream = ftp.GetRequestStream()
        stream.Write(file, 0, file.Length)
        stream.Close()
        stream.Dispose()
        Response.Redirect("/")
    End Sub


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>