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
 
B

bruce barker

the error means the dns lookup on the requested server name did not return an
ipaddress. check which dns server you web server uses.

-- bruce (sqlwork.com)
 
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
 
C

CindyH

Ok, thanks.


Patrice said:
Not really possible to know. Either you provided incorrect data, either
there is something wrong server side for the valid data you provided....

You can't do much more than double checking you provided good data
(possibly a sample case provided by this guy and that works would be fine
for testing) before getting in touch with the third party...

As a side note, you may want to check WebClient that will encode form data
for you (you just have to provide pairs of values). For some reason it
looks like I often see code that prefer to use the lowest level API even
when not really needed (to avoid having to swtich if you alter really need
it ?)...

Also a classic problem is not providing a user agent string or any other
http header that is used by the server side page...
 

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

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top