Windows XP HTTPS File Upload


Joined
Nov 4, 2009
Messages
1
Reaction score
0
Hi,

I am trying to upload test.txt file to remote server through HTTPS protocol.
for that on button click I have write the code as follows:


Protected Sub btnUploadFile_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUploadFile.Click
UploadFile("c:\test.txt", "https://remotemachine.com/test/files/")
End Sub

Public Sub UploadFile(ByVal localFile As String, ByVal uploadUrl As String)

Try

Dim req As HttpWebRequest
req = CType(WebRequest.Create(uploadUrl), HttpWebRequest)
req.KeepAlive = True

req.Credentials = New NetworkCredential("userName", "password")
req.ContentType = "Content-Type: multipart/form-data; boundary=BOUNDRY"

req.Method = "POST"

req.AllowWriteStreamBuffering = True

Dim reqStream As Stream
reqStream = req.GetRequestStream()

Dim rdr As New FileStream(localFile, FileMode.Open)
Dim inData(4096) As Byte

Dim bytesRead = rdr.Read(inData, 0, inData.Length - 1)
While bytesRead > 0
reqStream.Write(inData, 0, bytesRead)
bytesRead = rdr.Read(inData, 0, inData.Length - 1)
End While

rdr.Close()
reqStream.Close()

Dim objWebResponse As System.Net.HttpWebResponse
objWebResponse = CType(req.GetResponse, HttpWebResponse)

Catch ex As WebException
MsgBox("Error Message:" + ex.Message)
Finally
End Try

End Sub

But it raises an exception at
objWebResponse = CType(req.GetResponse, HttpWebResponse)
with message : The remote server returned an error : (405) Method Not Allowed

Can anyone please let me know as to how can i overcome this issue.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Windows XP https problems 10
Windows Vista Vista, IE7 & HTTPS 4
Windows XP Uploading and downloading massive files for free? 4
Windows XP slow uploading 3
Windows XP FTP upload speed 11
Windows XP MSN Photo Upload Control 3
Windows XP Re; Upload eMail addresses ? 0

Top