problem with url on http post

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
 
H

heintz.larry

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

From the machine that is running the code, are you able to Ping or
Tracert to the actual FQDN? Is port 800 open on the remote server or
is a firewall blocking this port? Are you able to telnet to the
address including the port?

Larry
 
C

CindyH

The guy gave me the wrong url address.
Now I'm able to send the post, but response is empty and getting this error:
system.net.webexception: The remote server returned an error: (500) Internal
Server Error.
Would this be my problem or his?
Thanks,
Cindy
 
K

kimiraikkonen

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

Hi,
Are you sure that you want to connect remote host using port 800
instead of 80? Http uses 80 by default.

And make sure url is valid and healty of course.(xx01x01 doesn't make
sense as a valid http domain without com or net or org... extension
alone)

Thanks,

Onur
 
H

heintz.larry

The guy gave me the wrong url address.
Now I'm able to send the post, but response is empty and getting this error:
system.net.webexception: The remote server returned an error: (500) Internal
Server Error.
Would this be my problem or his?
Thanks,
Cindy









- Show quoted text -

Normally you can get the exact 500 error when going to the URL
directly via a web browser. This will give you a better idea of what
the 500 internal error message is.

Larry
 
M

Michel Posseth [MCP]

"kimiraikkonen" <[email protected]> schreef in bericht
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

Hi,
Are you sure that you want to connect remote host using port 800
instead of 80? Http uses 80 by default.

And make sure url is valid and healty of course.(xx01x01 doesn't make
sense as a valid http domain without com or net or org... extension
alone)

Thanks,

Onur
Http uses 80 by default

normally 8080 is also open in the firewall because of corporate proxy
servers


Michel .
 
K

kimiraikkonen

"kimiraikkonen" <[email protected]> schreef in bericht




Hi,
Are you sure that you want to connect remote host using port 800
instead of 80? Http uses 80 by default.

And make sure url is valid and healty of course.(xx01x01 doesn't make
sense as a valid http domain without com or net or org... extension
alone)

Thanks,

Onur


normally 8080 is also open in the firewall because of corporate proxy
servers

Michel .- Hide quoted text -

- Show quoted text -

Yes, but IE and most of browsers assume port 80 to connect the remote
host unless you specify other port like 8080 or another.

"http://www.google.com" works and "http://www.google.com:80" works
also.

Thanks,

Onur Güzel
 

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

Top