C
CindyH
Hi:
I have the following code:
Dim url As String = "http://xx01xx01:800/some.ashx"
Dim myrequest As System.Net.WebRequest = Nothing
Dim myresponse As System.Net.WebResponse = Nothing
'Prepare web request
myrequest = System.Net.WebRequest.Create(url)
'use POST
myrequest.Method = "POST"
'Set the content type
Request.ContentType = "application/x-www-form-urlencoded"
Dim byteArray As Byte() =
System.Text.Encoding.UTF8.GetBytes(dataToPost)
'Get length of content
myrequest.ContentLength = byteArray.Length
'Get request stream
Dim newStream As System.IO.Stream = myrequest.GetRequestStream
'Send the data.
newStream.Write(byteArray, 0, byteArray.Length)
' Close stream
newStream.Close()
'Send the Post request and wait for the response.
myresponse = myrequest.GetResponse()
If I use for the first line something like this:
Dim url As String = "http://www.someplace.com/somepage.aspx" then
everything works fine, but now I need to use the real address which is
something like this: "http://xx01xx01:800/some.ashx"
When the code hits the line:
Dim newStream As System.IO.Stream = myrequest.GetRequestStream - I'm
getting the following error:
system.net.webexception: The remote name could not be resolved: 'xx01xx01'
Does anyone have any ideas why I'm having problems with the stream for a url
address like this?
Thanks,
Cindy
I have the following code:
Dim url As String = "http://xx01xx01:800/some.ashx"
Dim myrequest As System.Net.WebRequest = Nothing
Dim myresponse As System.Net.WebResponse = Nothing
'Prepare web request
myrequest = System.Net.WebRequest.Create(url)
'use POST
myrequest.Method = "POST"
'Set the content type
Request.ContentType = "application/x-www-form-urlencoded"
Dim byteArray As Byte() =
System.Text.Encoding.UTF8.GetBytes(dataToPost)
'Get length of content
myrequest.ContentLength = byteArray.Length
'Get request stream
Dim newStream As System.IO.Stream = myrequest.GetRequestStream
'Send the data.
newStream.Write(byteArray, 0, byteArray.Length)
' Close stream
newStream.Close()
'Send the Post request and wait for the response.
myresponse = myrequest.GetResponse()
If I use for the first line something like this:
Dim url As String = "http://www.someplace.com/somepage.aspx" then
everything works fine, but now I need to use the real address which is
something like this: "http://xx01xx01:800/some.ashx"
When the code hits the line:
Dim newStream As System.IO.Stream = myrequest.GetRequestStream - I'm
getting the following error:
system.net.webexception: The remote name could not be resolved: 'xx01xx01'
Does anyone have any ideas why I'm having problems with the stream for a url
address like this?
Thanks,
Cindy